diff options
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/enotez/README | 31 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/enotez/enotez_en.pdf | bin | 0 -> 684929 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/enotez/enotez_en.tex | 413 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/enotez/enotez_split_example.tex | 42 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/enotez/enotez.sty | 604 |
5 files changed, 1090 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/enotez/README b/Master/texmf-dist/doc/latex/enotez/README new file mode 100644 index 00000000000..f70411bb05e --- /dev/null +++ b/Master/texmf-dist/doc/latex/enotez/README @@ -0,0 +1,31 @@ +-------------------------------------------------------------------------- +the ENOTEZ package + + Endnotes for LaTeX2e + +2012/07/07 v0.3 +-------------------------------------------------------------------------- +Clemens Niederberger +Web: https://bitbucket.org/cgnieder/enotez/ +E-Mail: contact@mychemistry.eu +-------------------------------------------------------------------------- +Copyright 2012 Clemens Niederberger + +This work may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either version 1.3 +of this license or (at your option) any later version. +The latest version of this license is in + http://www.latex-project.org/lppl.txt +and version 1.3 or later is part of all distributions of LaTeX +version 2005/12/01 or later. + +This work has the LPPL maintenance status `maintained'. + +The Current Maintainer of this work is Clemens Niederberger. +-------------------------------------------------------------------------- +The enotez package consists of the files + - enotez.sty, enotez_en.tex, enotez_en.pdf, README +-------------------------------------------------------------------------- +If you have any ideas, questions, suggestions or bugs to report, please +feel free to contact me. +--------------------------------------------------------------------------
\ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/enotez/enotez_en.pdf b/Master/texmf-dist/doc/latex/enotez/enotez_en.pdf Binary files differnew file mode 100644 index 00000000000..7864fb976ca --- /dev/null +++ b/Master/texmf-dist/doc/latex/enotez/enotez_en.pdf diff --git a/Master/texmf-dist/doc/latex/enotez/enotez_en.tex b/Master/texmf-dist/doc/latex/enotez/enotez_en.tex new file mode 100644 index 00000000000..c3ad21abef4 --- /dev/null +++ b/Master/texmf-dist/doc/latex/enotez/enotez_en.tex @@ -0,0 +1,413 @@ +% arara: pdflatex +% arara: makeindex: { sort: true, style: enotez_en.ist } +% arara: biber +% arara: pdflatex +% arara: pdflatex +% -------------------------------------------------------------------------- +% the ENOTEZ package +% +% Endnotes for LaTeX2e +% +% -------------------------------------------------------------------------- +% Clemens Niederberger +% Web: https://bitbucket.org/cgnieder/enotez/ +% E-Mail: contact@mychemistry.eu +% -------------------------------------------------------------------------- +% Copyright 2011-2012 Clemens Niederberger +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Clemens Niederberger. +% -------------------------------------------------------------------------- +% The enotez package consists of the files +% - enotez.sty, enotez_en.tex, enotez_en.pdf, README +% -------------------------------------------------------------------------- +% If you have any ideas, questions, suggestions or bugs to report, please +% feel free to contact me. +% -------------------------------------------------------------------------- +\documentclass[toc=bib,toc=index]{cnpkgdoc} +\docsetup{ + pkg = enotez , + code-box = { + backgroundcolor = gray!7!white , + skipbelow = .6\baselineskip plus .5ex minus .5ex , + skipabove = .6\baselineskip plus .5ex minus .5ex , + roundcorner = 3pt , + } , + gobble = 1 , + subtitle = {Endnotes for \LaTeXe} +} + +\addcmds{ + appendix, + chapter, + cmd, + DeclareInstance, + DeclareTemplateInterface, + endnote, + endnotemark, + endnotetext, + enmark, + kant, + phantomsection, + printendnotes, + setenotez, + splitendnotes, + textsuperscript +} + +\DeclareInstance{enotez-list}{addsec}{paragraph}{heading=\addsec{#1}} + +% Layout: +\usepackage[osf]{libertine} +\cnpkgcolors{ + main => cnpkgred , + key => yellow!40!brown , + module => cnpkgblue , + link => black!90 +} +\renewcommand*\othersectionlevelsformat[3]{% + \textcolor{main}{#3\autodot}\enskip} +\renewcommand*\partformat{% + \textcolor{main}{\partname~\thepart\autodot}} +\usepackage{fnpct} +\AdaptNote\endnote\multendnote +\usepackage{embrac}[2012/06/29] +\ChangeEmph{[}[,.02em]{]}[.055em,-.08em] +\ChangeEmph{(}[-.01em,.04em]{)}[.04em,-.05em] + +\ExplSyntaxOn +\NewDocumentCommand \Default {g} + { + \hfill\llap + { + \IfNoValueTF { #1 } + {(initially~empty)} + {Default:~\code{#1}} + } + \newline + } +\ExplSyntaxOff + +\usepackage[backend=biber,style=alphabetic]{biblatex} +\addbibresource{\jobname.bib} + +% rudimentary solution for a `maintainer' field: +\DeclareFieldFormat{authortype}{\mkbibparens{#1}} +% \DeclareFieldAlias{maintainer}{author} +\DeclareBibliographyAlias{package}{misc} +\renewbibmacro*{author}{% + \ifboolexpr{ + test \ifuseauthor + and + not test {\ifnameundef{author}} + } + {\printnames{author}% + \iffieldundef{authortype} + {} + {\setunit{\space}% + \usebibmacro{authorstrg}}} + {}} + +\usepackage{filecontents} +\begin{filecontents*}{\jobname.bib} +@package{endnotes, + title = {endnotes}, + author = {Robin Fairbairns}, + authortype = {current maintainer}, + date = {2003-01-15}, + version = {NA}, + url = {http://www.ctan.org/pkg/endnotes}, + urldate = {2012-07-03} +} +@package{sepfootnotes, + title = {sepfootnotes}, + author = {Eduardo C. Louren\c{c}o de Lima}, + date = {2012-03-06}, + version = {0.1}, + url = {http://www.ctan.org/pkg/sepfootnotes}, + urldate = {2012-07-03} +} +\end{filecontents*} + +\usepackage{makeidx} +\begin{filecontents*}{\jobname.ist} + heading_prefix "{\\bfseries " + heading_suffix "\\hfil}\\nopagebreak\n" + headings_flag 1 + delim_0 "\\dotfill " + delim_1 "\\dotfill " + delim_2 "\\dotfill " + delim_r "\\textendash" + suffix_2p "\\nohyperpage{\\,f.}" + suffix_3p "\\nohyperpage{\\,ff.}" +\end{filecontents*} +\makeindex + +\usepackage{kantlipsum} +\usepackage{etoolbox} +\AtBeginEnvironment{beispiel}{\setfnpct{dont-mess-around}} +\usepackage{enumitem} +\begin{document} + +\section{Licence and Requirements} +Permission is granted to copy, distribute and/or modify this software under the +terms of the \LaTeX\ Project Public License, version 1.3 or later +(\url{http://www.latex-project.org/lppl.txt}). The package has the status +``maintained.'' + +\enotez needs and loads the following packages: \paket{expl3}, +\paket{xparse}, \paket{xtemplate} and \paket{l3keys2e}. If you're using +\paket{memoir}, a \paket[http://www.ctan.org/pkg/koma-script]{KOMA-Script} +class or the package \paket{caption} \enotez also needs and loads \paket{etoolbox}. + +\section{Motivation} +\enotez is a new implementation of endnotes for \LaTeXe\ since the \paket{endnotes} +package~\cite{endnotes} has some deficiencies. Nested endnotes, for example, are +not supported, neither is \paket{hyperref}. The \paket{sepfootnotes} package~\cite{sepfootnotes} +also provides means for endnotes but actually has a different purpose: to +separate input and usage both of footnotes and endnotes. So it might not be the +best solution in every case\footnote{You have to write the actual notes in the +preamble or a separate file and reference them in the text.}. It also does not +allow nested endnotes. + +\enotez enables nested endnotes properly and has another mechanism of customizing +the list of endnotes which is easily extendable. One of the main features of +\enotez is a splitted list of endnotes in which the notes are automatically +separated by the sections or chapters they were set in, see section~\ref{sec:split} +for more information. + +As an aside: \enotez is nicely compatible with the \paket{fnpct} package% +\footnote{You'll have to use \cmd*{AdaptNote} for the time being, though.}. + +\section{Usage} +\subsection{Placing the Notes} +The usage is simple: use \cmd{endnote} in the text where you want to place the +note mark. +\begin{beschreibung} + \befehl{endnote}[<mark>]{<text>} Add an endnote in the text. +\end{beschreibung} +\begin{beispiel} + This is some text.\endnote{With an endnote.} +\end{beispiel} +There's not really much more to it. It is possible to add a custom mark by +using the optional argument but that should be needed too often. \cmd{endnote} +works fine inside tables, minipages, floats and captions\footnote{This has been +tested with the standard classes, \paket*{memoir}, and the \paket*{KOMA-Script} +classes, with and without the \paket*{caption} package. If you're using another +package that redefines \cmd*{caption} it might not work.}. Endnotes can also be +nested. Since that seemed making a pair \cmd{endnotemark}/\cmd{endnotetext} +superfluous they are \emph{not} defined by \enotez. +\begin{beispiel} + This is some text.\endnote{With another endnote.\endnote{This is a + nested\endnote{And another level deeper\ldots} endnote!}} + % uses package `kantlipsum': + Of course you can have several paragraphs\endnote{\kant[1-3]} in an endnote. +\end{beispiel} + +\subsection{Printing the Notes} +The notes are printed by using the command \cmd{printendnotes}. +\begin{beschreibung} + \befehl{printendnotes}*[<style>] Print the list of endnotes. \code{<style>} is + one of the instances explained in section~\ref{ssec:customizing_the_list}. +\end{beschreibung} +If used without argument it prints all notes set so far with \cmd{endnote}. The +current list will then be cleared. All endnotes set after it are stored again +for the next usage of \cmd{printendnotes}. The starred version will print +\emph{all} endnotes but shouldn't be used more than once if you have nested +endnotes. + +It may take several compilation runs until all notes are printed correctly. In +a first run they are written to the \code{aux} file. In the second run they are +available to \cmd{printendnotes}. If you have nested endnotes they will be written +to the \code{aux} file the first time they're printed with \cmd{printendnotes} +which means you might have to compile your file once more. If you change any of +the endnotes or add another one you again will need at least two runs, maybe more. +\enotez tries to warn you in these cases by invoking \LaTeX's warning +\achtung{\code{Label(s) may have changed. Rerun to get cross-references right.}} +but may not catch all cases. + +\section{Options} +\subsection{Package Options} +\enotez has a few package options which should be pretty self-explanatory. They +can be set either as package options with \verb=\usepackage[<options>]{enotez}= +or with the setup command. +\begin{beschreibung} + \befehl{setenotez}{<options>} Setup command for setting \enotez' options. + \Option{list-name}{<list name>}\Default{Notes} + The name of the notes list. This name is used for the heading of the list. + \Option{reset}{\default{true}|false}\Default{false} + If set to \code{true} the notes numbers will start from 1 again after + \cmd{printendnotes} has been invoked. + \Option{counter-format}{arabic|alph|Alph|roman|Roman}\Default{arabic} + Change the format of the endnote counter. + \Option{totoc}{section|chapter|false}\Default{false} + Add an entry to the table of contents. + \Option{list-style}{<style>}\Default{plain} + Sets the default list style, see section \ref{ssec:customizing_the_list} for + details. +\end{beschreibung} + +\subsection{Customizing the List}\label{ssec:customizing_the_list} +The list is typeset with \paket{xtemplate}'s possibilities. \enotez declares +the object \code{enotez-list} and two templates for it, the template \code{paragraph} +and the template \code{list}. + +\subsubsection{The \code{paragraph} Template} +The \code{paragraph} template's interface is defined as follows: +\begin{beispiel}[code only] + \DeclareTemplateInterface{enotez-list}{paragraph}{1} + { + % parameter : type = default + heading : function 1 = \section*{#1} , + format : tokenlist = \footnotesize , + number : function 1 = \enmark{#1} , + number-format : tokenlist = \normalfont , + notes-sep : length = .5\baselineskip , + } +\end{beispiel} +The parameters functions are these: +\begin{description}[style=nextline] + \item[\code{heading}] The command with which the heading is typeset. + \item[\code{format}] The format of the whole list. + \item[\code{number}] The command that is used to typeset the numbers of the + notes. The command \cmd{enmark} is explained soon. + \item[\code{numbers-format}] The format of the numbers. + \item[\code{notes-sep}] Additional space between the notes. +\end{description} + +\enotez uses this template to define the instance \code{plain}: +\begin{beispiel}[code only] + \DeclareInstance{enotez-list}{plain}{paragraph}{} +\end{beispiel} +This is the default style of the list. + +You can easily define your own instances, though: +\begin{beispiel}[code only] + \DeclareInstance{enotez-list}{custom}{paragraph} + { + heading = \chapter*{#1} , + notes-sep = \baselineskip , + format = \normalfont , + number = \textsuperscript{#1} + } +\end{beispiel} +This would use a chapter heading for the title, separate the notes with +\verb=\baselineskip= and typeset them with \verb=\normalfont=. The numbers would +be typeset with \verb=\textsuperscript=. You could now use it like this: +\begin{beispiel}[code only] + \printendnotes[custom] +\end{beispiel} + +If you wanted superscripted numbers, you could also redefine \cmd{enmark}. +\begin{beschreibung} + \befehl{enmark} is defined like this: \verb=\newcommand*\enmark[1]{#1.}= +\end{beschreibung} + +\subsubsection{The \code{list} Template} +The \code{paragraph} template's interface is defined as follows: +\begin{beispiel}[code only] + \DeclareTemplateInterface{enotez-list}{list}{1} + { + % parameter : type = default + heading : function 1 = \section*{#1} , + format : tokenlist = \footnotesize , + number : function 1 = \enmark{#1} , + number-format : tokenlist = \normalfont , + list-type : tokenlist = description , + } +\end{beispiel} +This template uses a list to typeset the notes. As you can see the default list +is a \code{description} list. + +\enotez defines two instances of this template: +\begin{beispiel}[code only] + \DeclareInstance{enotez-list}{description}{list}{} + \DeclareInstance{enotez-list}{itemize}{list}{list-type = itemize} +\end{beispiel} +They're available through \cmd{printendnotes}[description] and +\cmd{printendnotes}[itemize], respectively. + +Again you can define your own instances using whatever list you want, possibly +one defined with the power of \paket{enumitem}. + +\section{Collect Notes Section-wise and Print List Stepwise}\label{sec:split} +\emph{This feature is experimental and has some limitations}. + +Not to be misunderstood: you can use \cmd{printendnotes} as often as you like, +possibly after each section. That is \emph{not} what is meant here. Let's +suppose you are writing a book and have many endnotes in many chapters. It +would be nice if the list of endnotes at the end of the book could be splitted +into parts for each chapter. This section describes how you can achieve that with +\enotez. + +First of all \enotez will rely on the fact that you use \cmd{printendnotes} +only \emph{once}! If you call it more times nobody knows what will happen\ldots + +You'll need to tell \enotez that you want to split the notes into groups. +\begin{beschreibung} + \Option{split}{section|chapter|false}\Default{false} + Enable the automatic splitting. + \Option{split-sectioning}{<csname>}\Default + The command that is used to display the titles between the splits. It needs + to be a command that takes one argument and should be entered without the + leading backslash. If the option is not used \enotez will choose + \code{subsection*} for \key*{split}{section} and \code{section*} for + \key*{split}{chapter}. + \Option{split-title}{<tokenlist>}\Default{Notes from <name> <ref>} + The title that will be inserted between the splits. \code{<name>} is replaced + by \code{Section} for \key*{split}{section} and \code{Chapter} for + \key*{split}{section}. \code{<ref>} is replaced by the corresponding + \cmd*{thesection} or \cmd*{thechapter}. +\end{beschreibung} +Set the \key{split} option: +\begin{beispiel}[code only] + \setenotez{split=section} +\end{beispiel} +Well -- that's it, basically. You'll have to be careful, though: +If you're having nested endnotes the nested ones appear first in the ``Notes'' +section (or chapter, respectively). In this case you should have a numbered +section title for the notes, presumably in the appendix. You'll need to create +a new list style: +\begin{beispiel}[code only] + % preamble: + \usepackage{enotez} + \DeclareInstance{enotez-list}{section}{paragraph}{heading=\section{#1}} + \setenotez{list-style=section,split=section} + % document: + \appendix + \printendnotes +\end{beispiel} + +Please beware that the option \key{reset} also impacts here: the numbing will +be reset for each section or chapter, depending on the choice you made for +\key{split}. + +\enotez comes with an example document for a splitted list which you should +find in the same folder as this documentation. + +\section{hyperref Support} +If \paket{hyperref} is loaded and you are using the option \key{totoc} (see +p~\pageref{key:totoc}) the list title is linked via a \verb=\phantomsection=. + +If \paket{hyperref} is used with \code{hyperfootnotes} set to \code{true} the +endnote marks are linked to the respective entries in the list. + +\printendnotes[addsec] + +{\EmbracOff\printbibliography} + +\setindexpreamble{Section titles are indicated \textbf{bold}, packages +\textsf{sans serif}, commands \code{\textbackslash\textcolor{code}{brown}} + and options \textcolor{key}{\code{yellow}}.\par\bigskip} + +\printindex +\end{document}
\ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/enotez/enotez_split_example.tex b/Master/texmf-dist/doc/latex/enotez/enotez_split_example.tex new file mode 100644 index 00000000000..df130cb1dcd --- /dev/null +++ b/Master/texmf-dist/doc/latex/enotez/enotez_split_example.tex @@ -0,0 +1,42 @@ +\documentclass{scrartcl} +\usepackage[T1]{fontenc} +\usepackage{libertine} + +\usepackage{enotez} +\usepackage{kantlipsum} + +\DeclareInstance{enotez-list}{section}{paragraph}{heading=\section{#1}} +\setenotez{split=section,list-style=section,reset} +% customize the titles in between, e.g.: +% \setenotez{split-sectioning=textbf,split-title=\par\noindent<name> <ref>:} + +\usepackage{fnpct} +\AdaptNote\endnote\multendnote + +\usepackage{mwe} +\usepackage[colorlinks]{hyperref} + +\begin{document} + +\tableofcontents + +\section{Test} +Text\endnote{\kant[1]}. Text\endnote{\kant[2]}. Text\endnote{This time +with a \textbf{nested}\multendnote{\kant[3];\kant[4]} endnote.}. +Text\multendnote{\kant[5];\kant[6]}. +\begin{figure}[htp] + \centering + \includegraphics[width=.4\linewidth]{example-image-a} + \caption[caption]{Some text\endnote{An endnote with a nested endnote\endnote{\kant[7]} + inside a figure caption.}.} +\end{figure} + +\section{Test} +Text\endnote{\kant[8]}. Text\endnote{\kant[9]}. Text\endnote{This time +with a \textbf{nested}\endnote{\kant[10]} endnote.}. Text\endnote{\kant[11]}. + +\appendix +\printendnotes + + +\end{document}
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/enotez/enotez.sty b/Master/texmf-dist/tex/latex/enotez/enotez.sty new file mode 100644 index 00000000000..67440c21388 --- /dev/null +++ b/Master/texmf-dist/tex/latex/enotez/enotez.sty @@ -0,0 +1,604 @@ +% -------------------------------------------------------------------------- +% the ENOTEZ package +% +% Endnotes for LaTeX2e +% +% -------------------------------------------------------------------------- +% Clemens Niederberger +% Web: https://bitbucket.org/cgnieder/enotez/ +% E-Mail: contact@mychemistry.eu +% -------------------------------------------------------------------------- +% Copyright 2011-2012 Clemens Niederberger +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Clemens Niederberger. +% -------------------------------------------------------------------------- +% The enotez package consists of the files +% - enotez.sty, enotez_en.tex, enotez_en.pdf, README +% -------------------------------------------------------------------------- +% If you have any ideas, questions, suggestions or bugs to report, please +% feel free to contact me. +% -------------------------------------------------------------------------- +\RequirePackage{ expl3 , xparse , l3keys2e , xtemplate } +\ProvidesExplPackage + {enotez} + {2012/07/07} + {0.3} + {Endnotes for LaTeX2e} + +% -------------------------------------------------------------------------- +% variables: +\bool_new:N \l_enotez_print_note_bool +\bool_new:N \l_enotez_reset_bool +\bool_new:N \l_enotez_totoc_bool +\bool_new:N \l_enotez_hyperref_bool +\bool_new:N \l_enotez_hyperfootnotes_bool +\bool_new:N \l_enotez_split_bool + +\tl_new:N \l_enotez_tmpa_tl +\tl_new:N \l_enotez_tmpb_tl +\tl_new:N \l_enotez_tmpc_tl +\tl_new:N \l_enotez_totoc_tl +\tl_new:N \l_enotez_list_name_tl +\tl_set:Nn \l_enotez_list_name_tl { Notes } +\tl_new:N \l_enotez_endnote_text_tl +\tl_new:N \l_enotez_endnote_mark_tl +\tl_new:N \l_enotez_list_instance_tl +\tl_set:Nn \l_enotez_list_instance_tl { plain } +\tl_new:N \l_enotez_split_tl +\tl_new:N \l_enotez_splitted_list_sectioning_tl +\tl_new:N \l_enotez_splitted_title_tl +\tl_set:Nn \l_enotez_splitted_title_tl { Notes~from~<name>~<ref> } +\tl_new:N \l_enotez_list_splitted_title_tl + +\int_new:N \g_enotez_endnote_id_int +\int_zero:N \g_enotez_endnote_id_int +\int_new:N \g_enotez_endnote_mark_int +\int_zero:N \g_enotez_endnote_mark_int +\int_new:N \g_enotez_list_printed_int +\int_zero:N \g_enotez_list_printed_int +\int_new:N \l_enotez_tmpa_int + +\prop_new:N \g_enotez_endnote_text_prop +\prop_new:N \g_enotez_endnote_mark_prop +\prop_new:N \g_enotez_endnote_split_prop +\prop_new:N \g_enotez_endnote_sect_prop +\prop_new:N \g_enotez_endnote_man_prop + +% -------------------------------------------------------------------------- +% options: +\cs_new_eq:NN \enotez_counter_format:n \int_to_arabic:n +\cs_generate_variant:Nn \enotez_counter_format:n { V } + +\keys_define:nn { enotez } + { + list-name .tl_set:N = \l_enotez_list_name_tl , + reset .bool_set:N = \l_enotez_reset_bool , + counter-format .choice_code:n = + \cs_set_eq:Nc \enotez_counter_format:n { int_to_ \l_keys_choice_tl :n } , + counter-format .generate_choices:n = + { arabic , alph , Alph , roman , Roman } , + totoc .choice_code:n = + \tl_if_eq:VnTF \l_keys_choice_tl { false } + { \bool_set_false:N \l_enotez_totoc_bool } + { + \bool_set_true:N \l_enotez_totoc_bool + \tl_set_eq:NN \l_enotez_totoc_tl \l_keys_choice_tl + } , + totoc .generate_choices:n = + { section , chapter , false } , + split .choice_code:n = + \tl_if_eq:VnTF \l_keys_choice_tl { false } + { \bool_set_false:N \l_enotez_split_bool } + { \bool_set_true:N \l_enotez_split_bool } + \tl_set_eq:NN \l_enotez_split_tl \l_keys_choice_tl , + split .generate_choices:n = + { section , chapter , false } , + split-sectioning .tl_set:N = \l_enotez_splitted_list_sectioning_tl , + split-title .tl_set:N = \l_enotez_splitted_title_tl , + list-style .tl_set:N = \l_enotez_list_instance_tl , + } +\cs_generate_variant:Nn \tl_if_eq:nnTF { Vn , nx } +\cs_generate_variant:Nn \tl_if_eq:nnT { xx } + +% -------------------------------------------------------------------------- +% typeset the actual mark: +% #1: id +% #2: mark +\cs_new:Npn \enotez_write_mark:nn #1#2 + { + \bool_if:NTF \l_enotez_hyperfootnotes_bool + { \textsuperscript { \hyperlink { enz.#1 } { #2 } } } + { \textsuperscript { #2 } } + } + +% the internal endnote: +\cs_new:Npn \enotez_endnote:nn #1#2 + { + \int_gincr:N \g_enotez_endnote_id_int + \IfNoValueTF { #1 } + { + \int_gincr:N \g_enotez_endnote_mark_int + \enotez_write_mark:nn + { \int_use:N \g_enotez_endnote_id_int } + { \enotez_counter_format:V \g_enotez_endnote_mark_int } + \tl_set:Nn \l_tmpa_tl { chapter } + \bool_if:nTF { \l_enotez_split_bool && \tl_if_eq_p:NN \l_enotez_split_tl \l_tmpa_tl } + { + \enotez_save_note:xxxxnn + { \int_use:N \g_enotez_endnote_id_int } + { \int_use:N \g_enotez_endnote_mark_int } + { \int_use:N \g_enotez_list_printed_int } + { \thechapter } + { a } + { #2 } + } + { + \enotez_save_note:xxxxnn + { \int_use:N \g_enotez_endnote_id_int } + { \int_use:N \g_enotez_endnote_mark_int } + { \int_use:N \g_enotez_list_printed_int } + { \thesection } + { a } + { #2 } + } + } + { + \enotez_write_mark:nn { \int_use:N \g_enotez_endnote_id_int } { #1 } + \tl_set:Nn \l_tmpa_tl { chapter } + \bool_if:nTF { \l_enotez_split_bool && \tl_if_eq_p:NN \l_enotez_split_tl \l_tmpa_tl } + { + \enotez_save_note:xnxxnn + { \int_use:N \g_enotez_endnote_id_int } + { #1 } + { \int_use:N \g_enotez_list_printed_int } + { \thechapter } + { m } + { #2 } + } + { + \enotez_save_note:xnxxnn + { \int_use:N \g_enotez_endnote_id_int } + { #1 } + { \int_use:N \g_enotez_list_printed_int } + { \thesection } + { m } + { #2 } + } + } + } + +% -------------------------------------------------------------------------- +% in some cases caption making commands need to be patched. preparations: +\cs_new:Npn \enotez_tmp_endnote:nn {} + +\cs_new:Npn \enotez_caption_endnote:nn #1#2 + { + \IfNoValueTF { #1 } + { + \enotez_write_mark:nn + { \int_use:N \g_enotez_endnote_id_int } + { \enotez_counter_format:V \g_enotez_endnote_mark_int } + } + { \enotez_write_mark:nn { \int_use:N \g_enotez_endnote_id_int } { #1 } } + } + +\cs_new:Npn \enotez@koma@disable + { \cs_set_eq:NN \enotez_endnote:nn \enotez_caption_endnote:nn } + +\cs_new:Npn \enotez@memoir@disable + { + \cs_set_eq:NN \enotez_tmp_endnote:nn \enotez_endnote:nn + \cs_set_eq:NN \enotez_endnote:nn \enotez_caption_endnote:nn + } + +\cs_new:Npn \enotez@memoir@enable + { \cs_set_eq:NN \enotez_endnote:nn \enotez_tmp_endnote:nn } + +\cs_new:Npn \enotez@caption@disable + { + \patchcmd \caption@@make + { \caption@@@make } + { \enotez@koma@disable\caption@@@make } + {}{} + } + +% if we're in a KOMA class, \@@makecaption needs to be patched: +\AtBeginDocument + { + \@ifpackageloaded { caption } + { \RequirePackage { etoolbox } \enotez@caption@disable } + { + \cs_if_free:NF \KOMAClassName + { + \RequirePackage { etoolbox } + \patchcmd \@@makecaption + { \setlength{\@tempdima}{\cap@width} } + { \enotez@koma@disable\setlength{\@tempdima}{\cap@width} }{}{} + } + } + } + +% if we're in memoir, \@makecaption needs to be patched: +\@ifclassloaded { memoir } + { + \AtBeginDocument + { + \@ifpackageloaded { caption } { } + { + \RequirePackage { etoolbox } + \patchcmd \@makecaption + { \let\@contfnote\footnote } + { \enotez@memoir@disable\let\@contfnote\footnote }{}{} + \patchcmd \@makecaption + { \let\footnote\@contfnote } + { \enotez@memoir@enable\let\footnote\@contfnote }{}{} + } + } + }{} + +% -------------------------------------------------------------------------- +% save the notes to the aux file: +% #1 global id +% #2 mark +% #3 split id +% #4 section/chapter +% #5 a/m (automatic/manually) +% #6 text +\cs_new:Npn \enotez_save_note:nnnnnn #1#2#3#4#5#6 + { \iow_now:Nn \@auxout { \enotez@note { #1 } { #2 } { #3 } { #4 } { #5 } { #6 } } } +\cs_generate_variant:Nn \enotez_save_note:nnnnnn { xxxxnn , xnxxnn } + +\cs_new:Npn \enotez@note #1#2#3#4#5#6 + { + \expandafter \xdef \csname enotez@#1@note \endcsname { #2 } + \prop_gput:Nnn \g_enotez_endnote_mark_prop { #1 } { #2 } + \prop_gput:Nnn \g_enotez_endnote_split_prop { #1 } { #3 } + \prop_gput:Nnn \g_enotez_endnote_sect_prop { #1 } { #4 } + \prop_gput:Nnn \g_enotez_endnote_man_prop { #1 } { #5 } + \prop_gput:Nnn \g_enotez_endnote_text_prop { #1 } { #6 } + } + +% a try to check if a rerun is necessary: +\AtEndDocument + { + \cs_set:Npn \enotez@note #1#2#3#4#5#6 + { + \def\reserved@a{#2} + \expandafter\ifx\csname enotez@#1@note \endcsname\reserved@a\else + \@tempswatrue\fi + } + } + +% -------------------------------------------------------------------------- +% the actual user command; I would use \NewDocumentCommand but that would +% disable compatibility with `fnpct' +\cs_new:Npn \endnote + { + \peek_meaning_ignore_spaces:NTF [ + { \enotez_endnote_aux:w } + { \enotez_endnote:nn { \NoValue } } + } + +\cs_new:Npn \enotez_endnote_aux:w [#1]#2 + { \enotez_endnote:nn { #1 } { #2 } } + +% -------------------------------------------------------------------------- +% the list of notes +\DeclareObjectType { enotez-list } { 1 } + +\DeclareTemplateInterface { enotez-list } { paragraph } { 1 } + { + heading : function 1 = \section*{#1} , + format : tokenlist = \footnotesize , + number : function 1 = \enmark{#1} , + number-format : tokenlist = \normalfont , + notes-sep : length = .5\baselineskip , + } + +\DeclareTemplateCode { enotez-list } { paragraph } { 1 } + { + heading = \enotez_list_heading:n , + format = \l_enotez_list_format_tl , + number = \enotez_list_number:n , + number-format = \l_enotez_list_number_format_tl , + notes-sep = \l_enotez_list_notes_sep_dim , + } + { + \AssignTemplateKeys + \bool_if:NT \l_enotez_totoc_bool + { + \bool_if:NT \l_enotez_hyperref_bool { \phantomsection } + \addcontentsline { toc } { \l_enotez_totoc_tl } { \l_enotez_list_name_tl } + } + \enotez_list_heading:n { \l_enotez_list_name_tl } + \group_begin: + \tl_use:N \l_enotez_list_format_tl + \int_zero:N \l_enotez_tmpa_int + \int_do_while:nn { \l_enotez_tmpa_int <= \g_enotez_list_printed_int } + { + \prop_map_inline:Nn \g_enotez_endnote_mark_prop + { + \tl_if_eq:xxT + { \int_use:N \l_enotez_tmpa_int } + { \prop_get:Nn \g_enotez_endnote_split_prop { ##1 } } + { + \enotez_get_split_title:n { ##1 } + \enotez_get_note:nn { #1 } { ##1 } + \bool_if:NT \l_enotez_print_note_bool + { + \par\noindent + \llap + { + \enotez_list_number:n + { + \bool_if:NT \l_enotez_hyperfootnotes_bool + { + \box_move_up:nn { 1em } + { \hbox:n { \hypertarget { enz.##1 } { } } } + } + \tl_use:N \l_enotez_list_number_format_tl + \tl_if_eq:nxTF { a } + { \prop_get:Nn \g_enotez_endnote_man_prop { ##1 } } + { \enotez_counter_format:V \l_enotez_endnote_mark_tl } + { \tl_use:N \l_enotez_endnote_mark_tl } + } + \tl_use:N \c_space_tl + } + \tl_use:N \l_enotez_endnote_text_tl + } + } + \par + \dim_compare:nT { \l_enotez_list_notes_sep_dim != 0pt } + { \addvspace { \l_enotez_list_notes_sep_dim } } + } + \int_incr:N \l_enotez_tmpa_int + } + \group_end: + } + +\DeclareTemplateInterface { enotez-list } { list } { 1 } + { + heading : function 1 = \section*{#1} , + format : tokenlist = \footnotesize , + number : function 1 = \enmark{#1} , + number-format : tokenlist = \normalfont , + list-type : tokenlist = description , + } + +\DeclareTemplateCode { enotez-list } { list } { 1 } + { + heading = \enotez_list_heading:n , + format = \l_enotez_list_format_tl , + number = \enotez_list_number:n , + number-format = \l_enotez_list_number_format_tl , + list-type = \l_enotez_list_type_tl + } + { + \AssignTemplateKeys + \bool_if:NT \l_enotez_totoc_bool + { + \bool_if:NT \l_enotez_hyperref_bool { \phantomsection } + \addcontentsline { toc } { \l_enotez_totoc_tl } { \l_enotez_list_name_tl } + } + \enotez_list_heading:n { \l_enotez_list_name_tl } + \group_begin: + \tl_use:N \l_enotez_list_format_tl + \int_zero:N \l_enotez_tmpa_int + \int_do_while:nn { \l_enotez_tmpa_int <= \g_enotez_list_printed_int } + { + \prop_map_inline:Nn \g_enotez_endnote_mark_prop + { + \tl_clear:N \l_enotez_tmpc_tl + \tl_if_eq:xxT + { \int_use:N \l_enotez_tmpa_int } + { \prop_get:Nn \g_enotez_endnote_split_prop { ##1 } } + { \tl_put_right:Nn \l_enotez_tmpc_tl { ##1 } } + \tl_if_blank:VF \l_enotez_tmpc_tl + { + \enotez_get_split_title:n { ##1 } + \begin{\l_enotez_list_type_tl} + } + \tl_if_eq:xxT + { \int_use:N \l_enotez_tmpa_int } + { \prop_get:Nn \g_enotez_endnote_split_prop { ##1 } } + { + \enotez_get_note:nn { #1 } { ##1 } + \bool_if:NT \l_enotez_print_note_bool + { + \item + [ + \enotez_list_number:n + { + \bool_if:NT \l_enotez_hyperfootnotes_bool + { + \box_move_up:nn { 1em } + { \hbox:n { \hypertarget { enz.##1 } { } } } + } + \tl_use:N \l_enotez_list_number_format_tl + \tl_if_eq:nxTF { a } + { \prop_get:Nn \g_enotez_endnote_man_prop { ##1 } } + { \enotez_counter_format:V \l_enotez_endnote_mark_tl } + { \tl_use:N \l_enotez_endnote_mark_tl } + } + ] + \tl_use:N \l_enotez_endnote_text_tl + } + } + \tl_if_blank:VF \l_enotez_tmpc_tl { \end{\l_enotez_list_type_tl} } + } + \int_incr:N \l_enotez_tmpa_int + } + \group_end: + } + +% some default styles: +\DeclareInstance { enotez-list } { plain } { paragraph } { } +\DeclareInstance { enotez-list } { description } { list } { } +\DeclareInstance { enotez-list } { itemize } { list } { list-type = itemize } + +% the titles in between the splits: +\cs_new:Npn \enotez_read_splitted_title:nn #1#2 + { + \group_begin: + \tl_set:Nn \l_tmpa_tl { #1 } + \tl_replace_all:Nnn \l_tmpa_tl { <name> } + { \enotez_first_upper:V \l_enotez_split_tl } + \tl_replace_all:Nnn \l_tmpa_tl { <ref> } + { \prop_get:Nn \g_enotez_endnote_sect_prop { #2 } } + \tl_use:N \l_tmpa_tl + \group_end: + } +\cs_generate_variant:Nn \enotez_read_splitted_title:nn { V } + +\cs_new:Npn \enotez_first_upper:n #1 + { \tl_to_uppercase:n { \tl_head:n { #1 } } \tl_tail:n { #1 } } +\cs_generate_variant:Nn \enotez_first_upper:n { V } + +% determine which note's next: +\cs_new:Npn \enotez_get_note:nn #1#2 + { + \IfBooleanTF { #1 } + { + \prop_get:NnN \g_enotez_endnote_mark_prop { #2 } \l_enotez_endnote_mark_tl + \prop_get:NnN \g_enotez_endnote_text_prop { #2 } \l_enotez_endnote_text_tl + \bool_set_true:N \l_enotez_print_note_bool + } + { + \prop_get:NnN \g_enotez_endnote_split_prop { #2 } \l_enotez_tmpa_tl + \bool_if:NTF \l_enotez_split_bool + { + \bool_set_true:N \l_enotez_print_note_bool + \prop_gpop:NnN \g_enotez_endnote_mark_prop { #2 } \l_enotez_endnote_mark_tl + \prop_gpop:NnN \g_enotez_endnote_text_prop { #2 } \l_enotez_endnote_text_tl + } + { + \int_compare:nTF { \l_enotez_tmpa_tl = \g_enotez_list_printed_int } + { + \bool_set_true:N \l_enotez_print_note_bool + \prop_gpop:NnN \g_enotez_endnote_mark_prop { #2 } \l_enotez_endnote_mark_tl + \prop_gpop:NnN \g_enotez_endnote_text_prop { #2 } \l_enotez_endnote_text_tl + \prop_gdel:Nn \g_enotez_endnote_split_prop { #2 } + } + { \bool_set_false:N \l_enotez_print_note_bool } + } + } + } + +\cs_new:Npn \enotez_get_split_title:n #1 + { + \prop_get:NnN \g_enotez_endnote_split_prop { #1 } \l_enotez_tmpa_tl + \bool_if:NT \l_enotez_split_bool + { + \tl_if_eq:NNF \l_enotez_tmpa_tl \l_enotez_tmpb_tl + { + \tl_if_blank:VTF \l_enotez_splitted_list_sectioning_tl + { + \tl_if_eq:VnTF \l_enotez_split_tl { section } + { \subsection* } + { \section* } + } + { \use:c { \l_enotez_splitted_list_sectioning_tl } } + { + \enotez_read_splitted_title:Vn + \l_enotez_splitted_title_tl { #1 } + } + } + } + \prop_get:NnN \g_enotez_endnote_split_prop { #1 } \l_enotez_tmpb_tl + } + +% the mark in the list: +\cs_new:Npn \enmark #1 { #1 . } + +% internal printendnotes: +\cs_new:Npn \enotez_print_endnotes:nn #1#2 + { + \IfNoValueTF { #2 } + { \UseInstance { enotez-list } { \l_enotez_list_instance_tl } } + { \UseInstance { enotez-list } { #2 } } + { #1 } + \bool_if:NF \l_enotez_split_bool + { + \bool_if:NTF \l_enotez_reset_bool + { \int_gzero:N \g_enotez_endnote_mark_int } + \int_gincr:N \g_enotez_list_printed_int + } + } + +% the user command: +\NewDocumentCommand \printendnotes { so } + { + \bool_if:NTF \l_enotez_split_bool + { \enotez_print_endnotes:nn { \BooleanFalse } { #2 } } + { \enotez_print_endnotes:nn { #1 } { #2 } } + } + +% -------------------------------------------------------------------------- +% process the options: +\ProcessKeysOptions { enotez } + +\AtBeginDocument + { + \bool_if:NT \l_enotez_split_bool + { + \tl_if_eq:VnTF \l_enotez_split_tl { section } + { + \tl_put_left:Nn \section + { + \int_gincr:N \g_enotez_list_printed_int + \bool_if:NT \l_enotez_reset_bool + { \int_gzero:N \g_enotez_endnote_mark_int } + } + } + { + \tl_put_left:Nn \chapter + { + \int_gincr:N \g_enotez_list_printed_int + \bool_if:NT \l_enotez_reset_bool + { \int_gzero:N \g_enotez_endnote_mark_int } + } + } + } + \@ifpackageloaded { hyperref } + { + \bool_set_true:N \l_enotez_hyperref_bool + \ifHy@hyperfootnotes + \bool_set_true:N \l_enotez_hyperfootnotes_bool + \else + \bool_set_false:N \l_enotez_hyperfootnotes_bool + \fi + } + { + \bool_set_false:N \l_enotez_hyperref_bool + \bool_set_false:N \l_enotez_hyperfootnotes_bool + } + } + +% -------------------------------------------------------------------------- +% the setup command: +\NewDocumentCommand \setenotez { +m } + { \keys_set:nn { enotez } { #1 } \ignorespaces } + +\tex_endinput:D +% -------------------------------------------------------------------------- +% HISTORY: +2012/07/03 v0.1 - first public version on bitbucket +2012/07/05 v0.2 - added preliminary `split' option + - enable endnotes in captions with KOMA classes, `memoir' and + the `caption' package +2012/07/06 v0.2a - made the splitted list titles customizable +2012/07/07 v0.3 - list-building rewritten due to a design flaw + +% -------------------------------------------------------------------------- +% TODO: +- make the headings obey the `totoc' option?
\ No newline at end of file |