diff options
author | Karl Berry <karl@freefriends.org> | 2015-10-03 23:09:59 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-10-03 23:09:59 +0000 |
commit | ff37512bde5f73a7c823f417675c27545da3dea0 (patch) | |
tree | a7d5c97bb7eee099fd991af962454fac94ac80e3 | |
parent | fe8d843c0480ab3531127a9407e6bc6ad34aeb41 (diff) |
acro (3oct15)
git-svn-id: svn://tug.org/texlive/trunk@38537 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/acro/README | 4 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/acro/acro_en.pdf | bin | 547227 -> 555835 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/acro/acro_en.tex | 338 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/acro/acro.sty | 721 |
4 files changed, 613 insertions, 450 deletions
diff --git a/Master/texmf-dist/doc/latex/acro/README b/Master/texmf-dist/doc/latex/acro/README index ad3168fceb1..557dbb68264 100644 --- a/Master/texmf-dist/doc/latex/acro/README +++ b/Master/texmf-dist/doc/latex/acro/README @@ -1,9 +1,9 @@ -------------------------------------------------------------------------- -the ACRO package v2.1 +the ACRO package v2.2 Typeset Acronyms -2015/09/05 +2015/10/03 -------------------------------------------------------------------------- Clemens Niederberger Web: http://www.mychemistry.eu/forums/forum/acro/ diff --git a/Master/texmf-dist/doc/latex/acro/acro_en.pdf b/Master/texmf-dist/doc/latex/acro/acro_en.pdf Binary files differindex ee81c0b7230..94ef7a2f76b 100644 --- a/Master/texmf-dist/doc/latex/acro/acro_en.pdf +++ b/Master/texmf-dist/doc/latex/acro/acro_en.pdf diff --git a/Master/texmf-dist/doc/latex/acro/acro_en.tex b/Master/texmf-dist/doc/latex/acro/acro_en.tex index e0f90fe47a0..fae8f17880d 100644 --- a/Master/texmf-dist/doc/latex/acro/acro_en.tex +++ b/Master/texmf-dist/doc/latex/acro/acro_en.tex @@ -1,5 +1,5 @@ % arara: pdflatex -% arara: biber +% !arara: biber % arara: pdflatex % arara: pdflatex % !arara: pdflatex @@ -56,8 +56,8 @@ acfplike, aciftrailing, acl, Acl, aclp, Aclp, acp, Acp, AcroRegisterTrailing, acs, Acs, acsp, Acsp, acspace, acreset, acresetall, acsetup, - DeclareAcroCommand, DeclareAcronym, DeclareAcronymCitation, - DeclareAcronymFormat, DeclareAcronymPDFString, DeclarePseudoAcroCommand, + DeclareAcroCommand, DeclareAcronym, DeclareAcroListHeading, + DeclareAcroListStyle, DeclarePseudoAcroCommand, iac, Iac, iaca, Iaca, iacs, Iacs, iacl, Iacl, iacf, Iacf, iacflike, Iacflike, NewAcroCommand, NewPseudoAcroCommand, @@ -74,6 +74,8 @@ \acsetup{hyperref} +\usepackage{varioref} + \defbibheading{bibliography}{\section{References}} \usepackage{csquotes} @@ -100,6 +102,14 @@ url = {http://en.wikipedia.org/wiki/New_York_City}, year = {2012} } +@manual{interface3, + author = {{The \LaTeX3 Project Team}} , + shorthand = {L3P} , + sortname = {LaTeX3 Project Team} , + title = {The \LaTeX3 Interfaces} , + date = {2015-09-06} , + url = {http://mirrors.ctan.org/macros/latex/contrib/l3kernel/interface3.pdf} +} \end{filecontents} % additional packages: @@ -109,6 +119,51 @@ \textsc{Wikipedia}} \newcommand*\h[1]{\textcolor{cnltx}{\textbf{#1}}} +\makeatletter +\def\cnltx@bash@listings@style{ + language = bash, + basicstyle = {\sourceformat\color{black}}, + % numbers = left, + % numberstyle = \tiny, + xleftmargin = 1em, + numbersep = .75em, + gobble = \cnltx@gobble , + columns = fullflexible, + literate = + {ä}{{\"a}}1 + {ö}{{\"o}}1 + {ü}{{\"u}}1 + {Ä}{{\"A}}1 + {Ö}{{\"O}}1 + {Ü}{{\"U}}1 + {ß}{{\ss}}1 , + breaklines = true, + keepspaces = true, + breakindent = 1em, + commentstyle = \color{comment}, + keywordstyle = \color{black}\bfseries , + stringstyle = \color{black} , + showstringspaces = false , + morekeywords = texdoc +} + +\cnltx@expandargs(nx)\lstdefinestyle + {bash} + {\expandonce\cnltx@bash@listings@style} + +\newcommand*\prompt{} +\patchcmd\lst@NewLine + {\hbox{}}% search + {\hbox{}\prompt}% replace + {}% success + {}% failure +\newsourcecodeenv[ + code-only, + sourcecode-options={style=bash}, + pre-code=\def\prompt{\textasciitilde\space\$\space} +]{bash} +\makeatother + \ProvideAcroEnding {possessive} {'s} {'s} % declare acronyms @@ -367,7 +422,7 @@ documentation. %% foreign \keyval{foreign}{original long form} \sinceversion{1.3}can be useful when dealing with acronyms in foreign - languages, see section~\ref{ssec:foreign} for details. + languages, see section~\vref{ssec:foreign} for details. %% sort \keyval{sort}{text} if used the acronym will be sorted according to this key instead of its @@ -410,16 +465,16 @@ documentation. occurrence of an acronym is recorded to the index and sorted by its \acs{id} or (if set) by the value of the \option{sort} key. This key allows to set an individual sorting option for the index. See - section~\ref{ssec:index} for details. + section~\vref{ssec:index} for details. %% index \keyval{index}{text} \sinceversion{1.1}This key allows to overwrite the automatic index entry - with an arbitrary one. See section~\ref{ssec:index} for details. + with an arbitrary one. See section~\vref{ssec:index} for details. %% index-cmd \keyval{index-cmd}{control sequence} \sinceversion{1.1}This key let's you set an individual index creating command for this acronym. It should be a command that takes one mandatory - argument. See section~\ref{ssec:index} for details. + argument. See section~\vref{ssec:index} for details. \end{options} In its simplest form an acronym needs a short and a long form. Please note @@ -622,7 +677,7 @@ with another key to \cs{DeclareAcronym}: Additional information for the list of acronyms. \end{options} These information will only be displayed in the list. See -section~\ref{sec:print_lists} for the impact of the following example. +section~\vref{sec:print_lists} for the impact of the following example. \begin{example} % preamble: @@ -735,7 +790,7 @@ Note that whatever text you're inserting might be gobbled depending on the \subsection{Using Classes} The acronyms of \acro\ can be divided into different classes. This doesn't change the output but allows different acronym lists, see -section~\ref{sec:print_lists}. For this \cs{DeclareAcronym} has an additional +section~\vref{sec:print_lists}. For this \cs{DeclareAcronym} has an additional key: \begin{options} \keyval{class}{text} @@ -946,7 +1001,7 @@ The commands takes a few options, namely the following ones: You can see that the default layout is a \code{description} list with a \cs*{section}\sarg\ title. Both can be changed, see -section~\ref{sec:customization}. +section~\vref{sec:customization}. The command \cs{printacronyms} needs two \LaTeX{} runs. This is a precaution to avoid error messages with a possibly empty list. But since almost all @@ -1221,21 +1276,21 @@ possible output forms of the acronyms. being there are many translations missing, yet. Please notify me if you find your language missing. %% - \keychoice{list-type}{table|\meta{list}}\Default{description} - This option let's you choose how the list is printed. \meta{list} can be - any valid list like \env{itemize} or \env{description}. - %% - \keychoice{list-style}{list,tabular,longtable,extra-tabular,extra-longtable,% - extra-tabular-rev,extra-longtable-rev}\Default{list} - If you choose \keyis{list-type}{table} you have to specify which kind of - table should be used. If you choose \code{longtable}, - \code{extra-longtable} or \code{extra-longtable-rev} you have to load - \pkg{longtable} in your preamble. The values \code{extra-longtable} and - \code{extra-longtable-rev} put the extra information in a column of its - own. + \keychoice{list-style}{description,lof,longtable,extra-longtable,% + extra-longtable-rev,extra-tabular,extra-tabular-rev,tabular,toc}% + \Default{description} + \changedversion{2.2}Choose with which style the list of acronyms should be + typeset. If you choose \meta{longtable}, \code{extra-longtable} or + \code{extra-longtable-rev} you have to load the + \pkg{longtable}~\cite{pkg:longtable} package in your preamble. The values + \code{extra-\meta{something}} put the extra information in a column of it + own. \emph{Be aware that per default \emph{all} \code{extra-table} styles + only use \code{l} columns. Since acronym descriptions can easily get + longer that a line you should probably define your own style if you want + to use them.} See section~\vref{sec:more-list-cust} for details. %% \keychoice{list-heading}{chapter,chapter*,section,section*,subsection,% - subsection*,subsubsection,subsubsection*,addchap,addsec,none}\null + subsection*,subsubsection,subsubsection*,addchap,addsec,none}% \Default{section*} \changedversion{2.0}The heading type of the list. The last two only work with a \KOMAScript{} class that also defines the appropriate command. A @@ -1247,51 +1302,9 @@ possible output forms of the acronyms. being there are many translations missing, yet. Please notify me if you find your language missing. %% - \keyval{list-table-width}{dimension}\Default{.7\cs*{columnwidth}} - This has only an effect if you chose \key{list-type}{table}. The - \emph{second} column (or the third if you choose one of the \code{-rev} - styles) of the table is a \code{p} column whose width can be specified - with this option. - %% \keybool{list-caps}\Default{false} Print the first letters of the long form capitalized. - \end{options} - -If you for example have loaded \pkg{enumitem} you can define a custom list for -the acronym list: -\begin{sourcecode} - % preamble: - % \usepackage{enumitem} - \newlist{acronyms}{description}{1} - \newcommand*\addcolon[1]{#1:} - \setlist[acronyms]{ - labelwidth=3em, - leftmargin=3.5em, - noitemsep, - itemindent=0pt, - font=\addcolon} - \acsetup{list-type=acronyms,hyperref=false,extra-style=comma} - \printacronyms -\end{sourcecode} -\newlist{acronyms}{description}{1} -\newcommand*\addcolon[1]{#1:} -\setlist[acronyms]{ - labelwidth=3em, - leftmargin=3.5em, - noitemsep, - itemindent=0pt, - font=\addcolon} -\acsetup{list-type=acronyms,extra-style=comma} -\printacronyms - -\subsection{Other Heading Command} -If you want a \option{list-heading} which is not yet provided you can add your -own option: -\begin{sourcecode} - \DeclareInstance{acro-title}{myname}{sectioning} - { name-format = command that uses #1 } -\end{sourcecode} -After that you could use \keyis{list-heading}{myname}. +\end{options} \section{Trailing Tokens and Special Action} @@ -1326,9 +1339,9 @@ must first be activated for this: list of the internal \emph{names} of the tokens. \end{options} -All the above on its own does nothing visible. However: inside of an acronym, -\ie, for example inside the long or the short form it can be tested for those -trailing options: +All of the above on its own does nothing visible. However: inside of an +acronym, \ie, for example inside the long or the short form it can be tested +for those trailing tokens: \begin{commands} \command{aciftrailing}[\marg{csv list of token names}\marg{true}\marg{false}] @@ -1342,9 +1355,10 @@ trailing options: \command{acspace} Inserts a \cs*{space} if no \code{dash} or \code{babel-hyphen} follows. \end{commands} -The definitions are equivalent to the following code: +The definitions are equivalent\footnote{Not \emph{quite}: \acro's definitions + are engine protected.} to the following code: \begin{sourcecode} - \newcommand*\acdot{\aciftrailing{dot}{}{.}} + \newcommand*\acdot{\aciftrailing{dot}{}{.\@}} \newcommand*\acspace{\aciftrailing{dash,babel-hyphen}{}{\space}} \end{sourcecode} @@ -1438,7 +1452,7 @@ they're on. \section{Defining Own Acronym Macros}\label{sec:defining-own-acronym} The commands\sinceversion{2.0}\sinceversion{2.0}\sinceversion{2.0} explained in -section~\ref{sec:using-acronyms-comm} have all been defined with a dedicated +section~\vref{sec:using-acronyms-comm} have all been defined with a dedicated command -- there is a family of dedicated commands, actually: \begin{commands} \command{NewAcroCommand}[\marg{cs}\marg{code}] @@ -1639,7 +1653,7 @@ The command's syntax and what it does is as follows: \item \option*{long-\meta{name}-form}. \end{itemize} Additionally it defines a setup macro as - described in section~\ref{sec:defining-own-acronym}, + described in section~\vref{sec:defining-own-acronym}, \cs*{acro_\meta{name}:}. If \meta{name} contains a \code{-} (dash) it is replaced by \code{\_} before \cs*{acro_\meta{name}:} is built. So if you choose \code{my-name} the corresponding macro is named @@ -1651,7 +1665,7 @@ The command's syntax and what it does is as follows: \end{commands} This could be used together with the macros described in -section~\ref{sec:defining-own-acronym} for adding support for possessive +section~\vref{sec:defining-own-acronym} for adding support for possessive forms: \begin{example} \ExplSyntaxOn @@ -1659,7 +1673,7 @@ forms: % it does nothing here: \ProvideAcroEnding {possessive} {'s} {'s} - \NewAcroCommand \acg + \ProvideAcroCommand \acg { \acro_possessive: \acro_use:n {#1} @@ -1685,38 +1699,162 @@ this you might want to consider \ProvideAcroEnding {possessive-plural} {s'} {s'} \end{sourcecode} -\appendix +\section{More on List Customization}\label{sec:more-list-cust} +\subsection{Own List Style} + +The different existing list styles are all built from four different +templates, \code{list}, \code{list-of}, \code{table} and \code{extra-table}. +Those templates are defined with the help of the \pkg{xtemplate} +package (from~\cite{bnd:l3packages}). Each of these templates has a few +options which are described in table~\vref{tab:list-templates}. New list +styles now are defined via the following macro: + +\begin{commands} + \command{DeclareAcroListStyle}[\marg{name}\marg{template}\marg{options}] + Declares a new \acro\ list style \meta{name}. \meta{name} will be the + value which can be chosen in the option \option{list-style}. + \meta{template} is the name of the template to be used by the style. + Available styles are listed in table~\ref{tab:list-templates}. + \meta{options} are the option settings for the corresponding template. +\end{commands} + +\begin{table} + \centering + \caption{Available List Templates and Their Options}\label{tab:list-templates} + \begin{tabular}{*{4}{>{\ttfamily}l}} + \toprule + \normalfont\bfseries Template & \normalfont\bfseries Option & + \normalfont\bfseries Option Type & \normalfont\bfseries Default \\ + \midrule + list & list & tokenlist & description \\ + & foreign-sep & tokenlist & \cs*{space} \\ + & reverse & boolean & false \\ + & before & tokenlist \\ + & after & tokenlist \\ + \midrule + list-of & style & tokenlist & toc \\ + & foreign-sep & tokenlist & \cs*{space} \\ + & reverse & boolean & false \\ + & before & tokenlist \\ + & after & tokenlist \\ + \midrule + table & table & tokenlist & tabular \\ + & table-spec & tokenlist & lp\{.7\cs*{linewidth}\} \\ + & foreign-sep & tokenlist & \cs*{space} \\ + & reverse & boolean & false \\ + & before & tokenlist \\ + & after & tokenlist \\ + \midrule + extra-table & table & tokenlist & tabular \\ + & table-spec & tokenlist & llll \\ + & foreign-sep & tokenlist & \cs*{space} \\ + & reverse & boolean & false \\ + & before & tokenlist \\ + & after & tokenlist \\ + \bottomrule + \end{tabular} +\end{table} + +For defining new styles you need some information on what the different +templates and options do: +\begin{itemize} + \item The option \code{list} of the \code{list} template sets the list + environment. This must be a classic \LaTeX\ list where items are listed + with \cs*{item}. In those lists short entries will always be fed as + optional argument to \cs*{item}: \\ + \code{\cs*{item}[\meta{short}]\meta{long}\meta{extra}\meta{page}} + \item The template \code{list-of} simulates a table of contents or a list of + figures. This can be chosen by setting the option \code{style} to either + \code{toc} or \code{lof}. + \item The template \code{table} typesets the list in a table with two + columns: \\ + \code{\meta{short} \& \meta{long}\meta{extra}\meta{page} + \cs*{tabularnewline}} + \item The template \code{extra-table} typesets the list in a table with four + columns: \\ + \code{\meta{short} \& \meta{long} \& \meta{extra} \& \meta{page} + \cs*{tabularnewline}} + \item The option \code{foreign-sep} is the code inserted between long form + and foreign entry (if a foreign entry is present). + \item The options \code{before} and \code{after} are inserted directly + before and after the complete list. + \item The option \code{reverse} switches the place of \meta{long} with + \meta{extra}. + \item The option \code{table-spec} sets the column types for the table + templates. It must correspond to the number of columns the corresponding + template uses. +\end{itemize} + +As an example let's define a style \code{longtabu} which uses the corresponding +table environment from the package \pkg{tabu}~\cite{pkg:tabu}: -\section{All Acronyms Used in this Documentation}\label{sec:documentation_acronyms} \begin{sourcecode} - \acsetup{ - list-type = table, - list-style = longtable, - list-heading = subsection*, - extra-style = comma, - page-ref = comma + \usepackage{tabu,longtable} + \DeclareAcroListStyle{longtabu}{table}{ + table = longtabu , + table-spec = @{}>{\bfseries}lX@{} } - \printacronyms[name=All Acronyms] + \acsetup{list-style=longtabu} \end{sourcecode} -\acsetup{ - list-type = table, - list-style = longtable, - list-heading = subsection*, - extra-style = comma, - page-ref = comma -} -\printacronyms[name=All Acronyms] + +As another example let's define a new list with the help of the \pkg{enumitem} +package~\cite{pkg:enumitem}: \begin{sourcecode} - \acsetup{ - list-type = table, - list-style = longtable, - list-heading = subsection*, - page-ref = comma - } - \printacronyms[include-classes=city,name=City Acronyms] + % preamble: + % \usepackage{enumitem} + \newlist{acronyms}{description}{1} + \newcommand*\addcolon[1]{#1:} + \setlist[acronyms]{ + labelwidth = 3em, + leftmargin = 3.5em, + noitemsep, + itemindent = 0pt, + font=\addcolon} + \DeclareAcroListStyle{mystyle}{list}{ list = acronyms } + \acsetup{ list-style = mystyle } +\end{sourcecode} +This would look as follows: +\newlist{acronyms}{description}{1} +\newcommand*\addcolon[1]{#1:} +\setlist[acronyms]{ + labelwidth=3em, + leftmargin=3.5em, + noitemsep, + itemindent=0pt, + font=\addcolon} +\DeclareAcroListStyle{mystyle}{list}{ list = acronyms } +\acsetup{list-style=mystyle,hyperref=false} +\printacronyms + +\subsection{Own List Heading Command} + +With the option \option{list-heading} you can choose which command prints the +heading of the list. If you need a different choice than what's already +provided you can use the following command to define a new option: +\begin{commands} + \command{DeclareAcroListHeading}[\marg{name}\marg{control sequence}] + Defines a new value \meta{name} for the option \option{list-heading}. + \meta{control sequence} must be a control sequence which takes one + mandatory argument. +\end{commands} +As an example here is how the value \code{section} is defined: +\begin{sourcecode} + \DeclareAcroListHeading{section}{\section} \end{sourcecode} -\printacronyms[include-classes=city,name=City Acronyms] + +\section{Configuration Files} +If\sinceversion{2.2} you repeatedly have the same setup and definitions for +\acro\ in your preamble you might want to place those in a configuration file. +If \acro\ finds a file named \code{acro.cfg} present it inputs it at the end +of the package. The only thing to be aware of is that this file is input like +a package which means that \code{@} is treated as a letterhas (category +code~12). + +\appendix + +\section{All Acronyms Used in this Documentation}\label{sec:documentation_acronyms} +\printacronyms[name=All Acronyms,heading=none] \end{document} diff --git a/Master/texmf-dist/tex/latex/acro/acro.sty b/Master/texmf-dist/tex/latex/acro/acro.sty index d9b996a194a..c8b8046c807 100644 --- a/Master/texmf-dist/tex/latex/acro/acro.sty +++ b/Master/texmf-dist/tex/latex/acro/acro.sty @@ -31,8 +31,8 @@ \RequirePackage{expl3,l3sort,xparse,l3keys2e,xtemplate,etoolbox} \ProvidesExplPackage {acro} - {2015/09/05} - {2.1} + {2015/10/03} + {2.2} {Typeset Acronyms} % -------------------------------------------------------------------------- @@ -87,6 +87,12 @@ form~ instead. } +\msg_new:nnn {acro} {unknown-list-style} + { + You're~ trying~ to~ use~ the~ list~ style~ `#1'~ which~ isn't~ defined.~ + Using~ `#2'~ instead. + } + % message macros: \cs_new:Npn \__acro_remove_backslash:N #1 { \exp_after:wN \use_none:n \token_to_str:N #1 } @@ -119,7 +125,7 @@ { \acro_harmless_message:nnnn {replaced} {option} {#1} {#2} } } \cs_new_protected:Npn \acro_option_deprecated:n #1 - { \cs_new_protected:Npn \acro_option_deprecated:nn {#1} {} } + { \acro_option_deprecated:nn {#1} {} } \cs_new_protected:Npn \acro_command_deprecated:NN #1#2 { @@ -160,9 +166,10 @@ \cs_generate_variant:Nn \prop_put:Nnn { NnV, cnx, cnv } \cs_generate_variant:Nn \prop_get:NnNF { cn, cnc } \cs_generate_variant:Nn \cs_generate_variant:Nn { c } +\cs_generate_variant:Nn \str_case:nn { V } % -------------------------------------------------------------------------- -% boolean variables: +% variables: \bool_new:N \l__acro_silence_bool \bool_new:N \l__acro_mark_as_used_bool \bool_new:N \g__acro_mark_first_as_used_bool @@ -212,9 +219,8 @@ \bool_set_true:N \l__acro_list_all_pages_bool \bool_new:N \g__acro_first_acronym_declared_bool \bool_new:N \l__acro_include_endings_format_bool +\bool_new:N \l__acro_list_reverse_long_extra_bool -% -------------------------------------------------------------------------- -% token list variables: \tl_new:N \l__acro_ignore_tl \tl_new:N \l__acro_short_format_tl \tl_new:N \l__acro_alt_format_tl @@ -246,13 +252,15 @@ \tl_new:N \l__acro_next_pages_tl \tl_set:Nn \l__acro_next_pages_tl { \,ff.\@ } \tl_new:N \l__acro_list_instance_tl -\tl_set:Nn \l__acro_list_instance_tl { list } +\tl_set:Nn \l__acro_list_instance_tl {description} \tl_new:N \l__acro_list_type_tl -\tl_set:Nn \l__acro_list_type_tl { description } +\tl_new:N \l__acro_list_tl \tl_new:N \l__acro_list_title_tl \tl_set:Nn \l__acro_list_title_tl { section* } \tl_new:N \l__acro_list_name_tl \tl_set:Nn \l__acro_list_name_tl { Acronyms } +\tl_new:N \l__acro_list_before_tl +\tl_new:N \l__acro_list_after_tl \tl_new:N \l__acro_short_tl \tl_new:N \l__acro_alt_tl \tl_new:N \l__acro_long_tl @@ -280,16 +288,13 @@ \tl_new:N \l__acro_single_form_tl \tl_set:Nn \l__acro_single_form_tl {long} -% -------------------------------------------------------------------------- -% length variables: -\dim_new:N \l__acro_table_width_dim -\AtBeginDocument - { \dim_set:Nn \l__acro_table_width_dim { .7\columnwidth } } \dim_new:N \l__acro_page_space_dim -\dim_new:N \l__acro_short_width_dim +\dim_new:N \l__acro_short_width_dim \dim_set:Nn \l__acro_short_width_dim {3em} +\prop_new:N \l__acro_list_styles_prop + % -------------------------------------------------------------------------- % small commands for use at various places \cs_new:Npn \acro_no_break: { \tex_penalty:D \c_ten_thousand } @@ -385,14 +390,9 @@ next-page .value_required:n = true , next-pages .tl_set:N = \l__acro_next_pages_tl , next-pages .value_required:n = true , - % TODO: get rid of list-type (set it implicitly?) - % proposed syntax: list-style = table : longtable - % with list-style = longtable - % being an alias if it is unique - list-style .tl_set:N = \l__acro_list_instance_tl , + list-style .code:n = \acro_set_list_style:n {#1} , list-style .value_required:n = true , - list-type .tl_set:N = \l__acro_list_type_tl , - list-type .value_required:n = true , + list-type .code:n = \acro_option_deprecated:n {list-type} , list-header .code:n = \acro_option_deprecated:nn {list-header} {list-heading} \tl_set:Nn \l__acro_list_title_tl {#1} , @@ -400,8 +400,8 @@ list-heading .value_required:n = true , list-name .tl_set:N = \l__acro_list_name_tl , list-name .value_required:n = true , - list-table-width .dim_set:N = \l__acro_table_width_dim , - list-table-width .value_required:n = true , + list-table-width .code:n = + \acro_option_deprecated:n {list-table-width} , hyperref .bool_set:N = \l__acro_use_hyperref_bool , only-used .bool_set:N = \l__acro_print_only_used_bool , mark-as-used .choice: , @@ -466,6 +466,34 @@ { \keys_set:nn {acro} {#1} \ignorespaces } % -------------------------------------------------------------------------- +% we use xtemplate for different object types and with a different number of +% arguments; let's declare functions for usage later so we don't have to +% bother + +% objects with one argument: +\cs_new_protected:Npn \acro_page_number_instance:nn #1#2 + { \UseInstance {acro-page-number} {#1} {#2} } +\cs_generate_variant:Nn \acro_page_number_instance:nn {V} + +\cs_new_protected:Npn \acro_extra_instance:nn #1#2 + { \UseInstance {acro-extra} {#1} {#2} } +\cs_generate_variant:Nn \acro_extra_instance:nn {VV} + +\cs_new_protected:Npn \acro_title_instance:nn #1#2 + { \UseInstance {acro-title} {#1} {#2} } +\cs_generate_variant:Nn \acro_title_instance:nn {VV} + +% objects with two arguments: +\cs_new_protected:Npn \acro_list_instance:nnn #1#2#3 + { \UseInstance {acro-list} {#1} {#2} {#3} } +\cs_generate_variant:Nn \acro_list_instance:nnn {VVV} + +% objects with three arguments: +\cs_new_protected:Npn \acro_first_instance:nnnn #1#2#3#4 + { \UseInstance {acro-first} {#1} {#2} {#3} {#4} } +\cs_generate_variant:Nn \acro_first_instance:nnnn {VnV,VnVV} + +% -------------------------------------------------------------------------- % hyperref support \cs_new_eq:NN \acro_hyper_target:nn \use_ii:nn \cs_new_eq:NN \acro_hyper_link:nn \use_ii:nn @@ -639,14 +667,14 @@ } % template for footnotes, sidenotes, ... -\DeclareTemplateInterface { acro-first } { note } { 3 } +\DeclareTemplateInterface {acro-first} {note} {3} { use-note : boolean = true , note-command : function 1 = \footnote {#1} , foreign-sep : tokenlist = ~ } -\DeclareTemplateCode { acro-first } { note } { 3 } +\DeclareTemplateCode {acro-first} {note} {3} { use-note = \l__acro_use_note_bool , note-command = \__acro_note_command:n , @@ -1002,37 +1030,33 @@ \acro_list_title_format:n {#1} } +\cs_new_protected:Npn \acro_declare_list_heading:nn #1#2 + { + \DeclareInstance {acro-title} {#1} {sectioning} + { name-format = #2 {##1} } + } + +\NewDocumentCommand \DeclareAcroListHeading {mm} + { \acro_declare_list_heading:nn {#1} {#2} } + % the different styles: -\DeclareInstance {acro-title} {chapter*} {sectioning} - { name-format = \chapter* {#1} } -\DeclareInstance {acro-title} {part*} {sectioning} - { name-format = \part* {#1} } -\DeclareInstance {acro-title} {section*} {sectioning} - { name-format = \section* {#1} } -\DeclareInstance {acro-title} {subsection*} {sectioning} - { name-format = \subsection* {#1} } -\DeclareInstance {acro-title} {subsubsection*} {sectioning} - { name-format = \subsubsection* {#1} } -\DeclareInstance {acro-title} {chapter} {sectioning} - { name-format = \chapter {#1} } -\DeclareInstance {acro-title} {part} {sectioning} - { name-format = \part {#1} } -\DeclareInstance {acro-title} {section} {sectioning} - { name-format = \section {#1} } -\DeclareInstance {acro-title} {subsection} {sectioning} - { name-format = \subsection {#1} } -\DeclareInstance {acro-title} {subsubsection} {sectioning} - { name-format = \subsubsection {#1} } -\DeclareInstance {acro-title} {addchap} {sectioning} - { name-format = \addchap {#1} } -\DeclareInstance {acro-title} {addsec} {sectioning} - { name-format = \addsec {#1} } -\DeclareInstance {acro-title} {none} {sectioning} - { name-format = \use_none:n {#1} } +\acro_declare_list_heading:nn {part} {\part} +\acro_declare_list_heading:nn {part*} {\part*} +\acro_declare_list_heading:nn {chapter} {\chapter} +\acro_declare_list_heading:nn {chapter*} {\chapter*} +\acro_declare_list_heading:nn {addchap} {\addchap} +\acro_declare_list_heading:nn {section} {\section} +\acro_declare_list_heading:nn {section*} {\section*} +\acro_declare_list_heading:nn {addsec} {\addsec} +\acro_declare_list_heading:nn {subsection} {\subsection} +\acro_declare_list_heading:nn {subsection*} {\subsection*} +\acro_declare_list_heading:nn {subsubsection} {\subsubsection} +\acro_declare_list_heading:nn {subsubsection*} {\subsubsection*} +\acro_declare_list_heading:nn {none} {\use_none:n} % -------------------------------------------------------------------------- -% outputting the whole list -\DeclareObjectType {acro-list} {3} +% typesetting the acronym list +\DeclareObjectType {acro-list} {2} % #1: id % #2: excluded classes @@ -1053,11 +1077,68 @@ } } -% build the list, dummy functions to be redefined in the template code: -\cs_new:Npn \acro_print_list_short:nn #1#2 { } -\cs_new:Npn \acro_print_list_long:n #1 { } -\cs_new:Npn \acro_print_list_extra:n #1 { } -\cs_new:Npn \acro_print_list_page:n #1 { } +% build the list: default functions, may be redefined in the template code +\cs_new_protected:Npn \acro_print_list_short:nn #1#2 + { \acro_list_short_entry:nn {#1} {#2} } +\cs_new_protected:Npn \acro_print_list_long:n #1 + { \acro_list_long_entry:n {#1} } +\cs_new_protected:Npn \acro_print_list_extra:n #1 + { \acro_list_extra_entry:n {#1} } +\cs_new_protected:Npn \acro_print_list_page:n #1 + { \acro_list_page_entry:n {#1} } + +% macros for standard retrieval of items in the list: +\cs_new_protected:Npn \acro_list_short_entry:nn #1#2 + { + \acro_hyper_target:nn + {#1} + { + \acro_acc_supp:nn + {#1} + { \acro_write_short:nn {#1} { \l__acro_list_short_format_tl {#2} } } + } + } + +\cs_set_protected:Npn \acro_list_long_entry:n #1 + { + \group_begin: + \bool_if:NT \l__acro_capitalize_list_bool + { \bool_set_true:N \l__acro_first_upper_bool } + \acro_write_long:Vf \l__acro_list_long_format_tl + { \prop_item:Nn \l__acro_long_prop {#1} } + \group_end: + \bool_if:NT \l__acro_foreign_bool + { \acro_get_foreign:n {#1} } + \acro_cite_if:Nn \l__acro_citation_all_bool {#1} + } + +\cs_set_protected:Npn \acro_list_extra_entry:n #1 + { + \prop_get:NnNT \l__acro_extra_prop {#1} \l__acro_tmpa_tl + { + \acro_extra_instance:VV + \l__acro_extra_instance_tl + \l__acro_tmpa_tl + } + } + +\cs_set_protected:Npn \acro_list_page_entry:n #1 + { + \bool_if:nT { \cs_if_exist_p:c { acro@#1@once } } + { + \acro_page_number_instance:Vn + \l__acro_page_instance_tl + {#1} + } + } + +% this macro may be redefined in templates: +% #1: short +% #2: long +% #3: extra +% #4: page number(s) +\cs_new_protected:Npn \acro_print_list_entry:nnnn #1#2#3#4 + { #1 #2 #3 #4 } \cs_new:Npn \acroenparen #1 { ( #1 ) } @@ -1076,9 +1157,10 @@ \cs_new_protected:Npn \acro_for_all_acronyms_do:n #1 { \prop_map_inline:Nn \l__acro_short_prop {#1} } -% Test, if acronyms should be printed or not; needs testing for in/excluded -% classes and options `only-used' and `single': -\cs_new_protected:Npn \acro_list_allow_items:nn #1#2 +% test, if acronyms should be printed or not; needs testing for in/excluded +% classes and options `only-used' and `single' -- this macro should be used in +% the template code for retrieving the list +\cs_new_protected:Npn \acro_list_items:nn #1#2 { \acro_for_all_acronyms_do:n { @@ -1103,17 +1185,10 @@ { \tl_if_blank:nTF {#1} { - \acro_print_list_entry:nnn + \acro_print_list_entry:nnnn { \acro_print_list_short:nn {##1} {##2} } - { - \bool_if:NT \l__acro_capitalize_list_bool - { \bool_set_true:N \l__acro_first_upper_bool } - \acro_print_list_long:n {##1} - \bool_set_false:N \l__acro_first_upper_bool - \bool_if:NT \l__acro_foreign_bool - { \acro_get_foreign:n {##1} } - \acro_print_list_extra:n {##1} - } + { \acro_print_list_long:n {##1} } + { \acro_print_list_extra:n {##1} } { \acro_print_list_page:n {##1} } } { @@ -1126,17 +1201,10 @@ \tl_trim_spaces:N \l__acro_tmpb_tl \tl_if_eq:NNT \l__acro_tmpa_tl \l__acro_tmpb_tl { - \acro_print_list_entry:nnn + \acro_print_list_entry:nnnn { \acro_print_list_short:nn {##1} {##2} } - { - \bool_if:NT \l__acro_capitalize_list_bool - { \bool_set_true:N \l__acro_first_upper_bool } - \acro_print_list_long:n {##1} - \bool_set_false:N \l__acro_first_upper_bool - \bool_if:NT \l__acro_foreign_bool - { \acro_get_foreign:n {##1} } - \acro_print_list_extra:n {##1} - } + { \acro_print_list_long:n {##1} } + { \acro_print_list_extra:n {##1} } { \acro_print_list_page:n {##1} } } } @@ -1147,68 +1215,66 @@ } } +% -------------------------------------------------------------------------- +% declare templates for the list: % list template: -\DeclareTemplateInterface {acro-list} {list} {3} - { foreign-sep : tokenlist = { ~ } } +\DeclareTemplateInterface {acro-list} {list} {2} + { + foreign-sep : tokenlist = {~} , + list : tokenlist = {description} , + reverse : boolean = false , + before : tokenlist = , + after : tokenlist = + } -\DeclareTemplateCode {acro-list} {list} {3} - { foreign-sep = \l__acro_foreign_sep_tl } +\DeclareTemplateCode {acro-list} {list} {2} + { + foreign-sep = \l__acro_foreign_sep_tl , + list = \l__acro_list_tl , + reverse = \l__acro_list_reverse_long_extra_bool , + before = \l__acro_list_before_tl , + after = \l__acro_list_after_tl + } { \AssignTemplateKeys \bool_set_true:N \l__acro_in_list_bool \acro_activate_hyperref_support: - \cs_set_eq:NN \acro_print_list_entry:nnn \use:nnn - \cs_set_protected:Npn \acro_print_list_short:nn ##1##2 + \bool_if:NTF \l__acro_list_reverse_long_extra_bool { - \item - [ - \acro_hyper_target:nn - {##1} - { - \acro_acc_supp:nn - {##1} - { \acro_write_short:nn {##1} { \l__acro_list_short_format_tl {##2} } } - } - ] + \cs_set_protected:Npn \acro_print_list_entry:nnnn ##1##2##3##4 + { \item [##1] ##3 ##2 ##4 } } - \cs_set_protected:Npn \acro_print_list_long:n ##1 { - \acro_write_long:Vf \l__acro_list_long_format_tl - { - \prop_if_in:NnTF \l__acro_list_prop {##1} - { \prop_item:Nn \l__acro_list_prop {##1} } - { \prop_item:Nn \l__acro_long_prop {##1} } - } - \acro_cite_if:Nn \l__acro_citation_all_bool {##1} + \cs_set_protected:Npn \acro_print_list_entry:nnnn ##1##2##3##4 + { \item [##1] ##2 ##3 ##4 } } - \cs_set_protected:Npn \acro_print_list_extra:n ##1 - { - \prop_get:NnNT \l__acro_extra_prop {##1} \l__acro_tmpa_tl - { - \UseInstance {acro-extra} { \l__acro_extra_instance_tl } - { \l__acro_tmpa_tl } - } - } - \cs_set_protected:Npn \acro_print_list_page:n ##1 + \use:x { - \bool_if:nT { \cs_if_exist_p:c { acro@##1@once } } - { \UseInstance {acro-page-number} { \l__acro_page_instance_tl } {##1} } + \exp_not:V \l__acro_list_before_tl + \exp_not:N \begin { \exp_not:V \l__acro_list_tl } + \exp_not:n { \acro_list_items:nn {#1} {#2} } + \exp_not:N \end { \exp_not:V \l__acro_list_tl } + \exp_not:V \l__acro_list_after_tl } - \begin {#1} - \acro_list_allow_items:nn {#2} {#3} - \end {#1} } -\DeclareTemplateInterface {acro-list} {list-of} {3} +% list-of template: +\DeclareTemplateInterface {acro-list} {list-of} {2} { - foreign-sep : tokenlist = { ~ } , - style : tokenlist = {toc} + foreign-sep : tokenlist = {~} , + style : tokenlist = {toc} , + reverse : boolean = false , + before : tokenlist = , + after : tokenlist = } -\DeclareTemplateCode {acro-list} {list-of} {3} +\DeclareTemplateCode {acro-list} {list-of} {2} { foreign-sep = \l__acro_foreign_sep_tl , - style = \l__acro_list_of_style + style = \l__acro_list_of_style , + reverse = \l__acro_list_reverse_long_extra_bool , + before = \l__acro_list_before_tl , + after = \l__acro_list_after_tl } { \AssignTemplateKeys @@ -1218,20 +1284,43 @@ \tl_set:Nn \l__acro_page_name_tl {} \tl_set:Nn \l__acro_pages_name_tl {} \acro_activate_hyperref_support: - \srt_case:NnF \l__acro_list_of_style + \str_case:Vn \l__acro_list_of_style { {toc} { % similar to the table of contents - \cs_set_protected:Npn \acro_print_list_entry:nnn ##1##2##3 + \bool_if:NTF \l__acro_list_reverse_long_extra_bool + { + \cs_if_exist:NTF \chapter + { + \cs_set_protected:Npn \acro_print_list_entry:nnnn ##1##2##3##4 + { + \contentsline{chapter}{##1}{}{} + \contentsline{section}{##3##2}{##4}{} + } + } + { + \cs_set_protected:Npn \acro_print_list_entry:nnnn ##1##2##3##4 + { + \contentsline{section}{##1}{}{} + \contentsline{subsection}{##3##2}{##4}{} + } + } + } { \cs_if_exist:NTF \chapter { - \contentsline{chapter}{##1}{}{} - \contentsline{section}{##2}{##3}{} + \cs_set_protected:Npn \acro_print_list_entry:nnnn ##1##2##3##4 + { + \contentsline{chapter}{##1}{}{} + \contentsline{section}{##2##3}{##4}{} + } } { - \contentsline{section}{##2}{##3}{} - \contentsline{subsection}{##2}{##3}{} + \cs_set_protected:Npn \acro_print_list_entry:nnnn ##1##2##3##4 + { + \contentsline{section}{##1}{}{} + \contentsline{subsection}{##2##3}{##4}{} + } } } } @@ -1239,261 +1328,182 @@ { % similar to the list of figures \cs_set_protected:Npn \l@acro { \@dottedtocline {1} {1.5em} {\l__acro_short_width_dim} } - \cs_set_protected:Npn \acro_print_list_entry:nnn ##1##2##3 + \bool_if:NTF \l__acro_list_reverse_long_extra_bool { - \contentsline{acro}{\numberline{##1}{##2}}{##3}{} + \cs_set_protected:Npn \acro_print_list_entry:nnnn ##1##2##3##4 + { \contentsline{acro}{\numberline{##1}{##3##2}}{##4}{} } + } + { + \cs_set_protected:Npn \acro_print_list_entry:nnnn ##1##2##3##4 + { \contentsline{acro}{\numberline{##1}{##2##3}}{##4}{} } } } } - { \ERROR } - \cs_set_protected:Npn \acro_print_list_short:nn ##1##2 - { - \acro_hyper_target:nn - {##1} - { - \acro_acc_supp:nn - {##1} - { \acro_write_short:nn {##1} { \l__acro_list_short_format_tl {##2} } } - } - } - \cs_set_protected:Npn \acro_print_list_long:n ##1 - { - \acro_write_long:Vf \l__acro_list_long_format_tl - { - \prop_if_in:NnTF \l__acro_list_prop {##1} - { \prop_item:Nn \l__acro_list_prop {##1} } - { \prop_item:Nn \l__acro_long_prop {##1} } - } - \acro_cite_if:Nn \l__acro_citation_all_bool {##1} - } - \cs_set_protected:Npn \acro_print_list_extra:n ##1 - { - \prop_get:NnNT \l__acro_extra_prop {##1} \l__acro_tmpa_tl - { - \UseInstance {acro-extra} { \l__acro_extra_instance_tl } - { \l__acro_tmpa_tl } - } - } - \cs_set_protected:Npn \acro_print_list_page:n ##1 + \use:x { - \bool_if:nT { \cs_if_exist_p:c {acro@##1@once} } - { \UseInstance {acro-page-number} { \l__acro_page_instance_tl } {##1} } + \exp_not:V \l__acro_list_before_tl + \exp_not:n { \acro_list_items:nn {#1} {#2} } + \exp_not:V \l__acro_list_before_tl } - % \begin {#1} - \acro_list_allow_items:nn {#2} {#3} - % \end {#1} } % table template: -\DeclareTemplateInterface {acro-list} {table} {3} +\DeclareTemplateInterface {acro-list} {table} {2} { - table : tokenlist = longtable , - table-spec : tokenlist = lp{\l__acro_table_width_dim} , - foreign-sep : tokenlist = { ~ } + table : tokenlist = tabular , + table-spec : tokenlist = lp{.7\linewidth} , + foreign-sep : tokenlist = {~} , + reverse : boolean = false , + before : tokenlist = , + after : tokenlist = } -\DeclareTemplateCode {acro-list} {table} {3} +\DeclareTemplateCode {acro-list} {table} {2} { table = \l__acro_list_table_tl , table-spec = \l__acro_list_table_spec_tl , - foreign-sep = \l__acro_foreign_sep_tl + foreign-sep = \l__acro_foreign_sep_tl , + reverse = \l__acro_list_reverse_long_extra_bool , + before = \l__acro_list_before_tl , + after = \l__acro_list_after_tl } { \AssignTemplateKeys \acro_activate_hyperref_support: - \cs_set_eq:NN \acro_print_list_entry:nnn \use:nnn - \cs_set_protected:Npn \acro_print_list_short:nn ##1##2 - { - \acro_hyper_target:nn - {##1} - { - \acro_acc_supp:nn - {##1} - { \acro_write_short:nn {##1} { \l__acro_list_short_format_tl {##2} } } - } - & - } - \cs_set_protected:Npn \acro_print_list_long:n ##1 - { - \acro_write_long:Vf \l__acro_list_long_format_tl - { - \prop_if_in:NnTF \l__acro_list_prop {##1} - { \prop_item:Nn \l__acro_list_prop {##1} } - { \prop_item:Nn \l__acro_long_prop {##1} } - } - \acro_cite_if:Nn \l__acro_citation_all_bool {##1} - } - \cs_set_protected:Npn \acro_print_list_extra:n ##1 + \bool_if:NTF \l__acro_list_reverse_long_extra_bool { - \prop_get:NnNT \l__acro_extra_prop {##1} \l__acro_tmpa_tl - { - \UseInstance {acro-extra} { \l__acro_extra_instance_tl } - { \l__acro_tmpa_tl } - } + \cs_set_protected:Npn \acro_print_list_entry:nnnn ##1##2##3##4 + { ##1 & ##3 ##2 ##4 \tabularnewline } } - \cs_set_protected:Npn \acro_print_list_page:n ##1 { - \bool_if:nT { \cs_if_exist_p:c { acro@##1@once } } - { \UseInstance {acro-page-number} { \l__acro_page_instance_tl } {##1} } - \tabularnewline + \cs_set_protected:Npn \acro_print_list_entry:nnnn ##1##2##3##4 + { ##1 & ##2 ##3 ##4 \tabularnewline } } \use:x { + \exp_not:V \l__acro_list_before_tl \exp_not:N \begin { \exp_not:V \l__acro_list_table_tl } { \exp_not:V \l__acro_list_table_spec_tl } - \exp_not:n { \acro_list_allow_items:nn {#2} {#3} } + \exp_not:n { \acro_list_items:nn {#1} {#2} } \exp_not:N \end { \exp_not:V \l__acro_list_table_tl } + \exp_not:V \l__acro_list_after_tl } } % extra-table template: -\DeclareTemplateInterface {acro-list} {extra-table} {3} +\DeclareTemplateInterface {acro-list} {extra-table} {2} { - table : tokenlist = longtable , - table-spec : tokenlist = lp{\l__acro_table_width_dim}ll + table : tokenlist = tabular , + table-spec : tokenlist = llll , + foreign-sep : tokenlist = {~} , + reverse : boolean = false , + before : tokenlist = , + after : tokenlist = } -\DeclareTemplateCode {acro-list} {extra-table} {3} +\DeclareTemplateCode {acro-list} {extra-table} {2} { - table = \l__acro_list_table_tl , - table-spec = \l__acro_list_table_spec_tl + table = \l__acro_list_table_tl , + table-spec = \l__acro_list_table_spec_tl , + foreign-sep = \l__acro_foreign_sep_tl , + reverse = \l__acro_list_reverse_long_extra_bool , + before = \l__acro_list_before_tl , + after = \l__acro_list_after_tl } { \AssignTemplateKeys \acro_activate_hyperref_support: - \cs_set_eq:NN \acro_print_list_entry:nnn \use:nnn - \cs_set_protected:Npn \acro_print_list_short:nn ##1##2 + \bool_if:NTF \l__acro_list_reverse_long_extra_bool { - \acro_hyper_target:nn - {##1} - { - \acro_acc_supp:nn - {##1} - { \acro_write_short:nn {##1} { \l__acro_list_short_format_tl {##2} } } - } - & + \cs_set_protected:Npn \acro_print_list_entry:nnnn ##1##2##3##4 + { ##1 & ##3 & ##2 & ##4 \tabularnewline } } - \cs_set_protected:Npn \acro_print_list_long:n ##1 { - \acro_write_long:Vf \l__acro_list_long_format_tl - { - \prop_if_in:NnTF \l__acro_list_prop {##1} - { \prop_item:Nn \l__acro_list_prop {##1} } - { \prop_item:Nn \l__acro_long_prop {##1} } - } - \acro_cite_if:Nn \l__acro_citation_all_bool {##1} - & + \cs_set_protected:Npn \acro_print_list_entry:nnnn ##1##2##3##4 + { ##1 & ##2 & ##3 & ##4 \tabularnewline } } - \cs_set_protected:Npn \acro_print_list_extra:n ##1 - { - \prop_get:NnNT \l__acro_extra_prop {##1} \l__acro_tmpa_tl - { - \UseInstance {acro-extra} { \l__acro_extra_instance_tl } - { \l__acro_tmpa_tl } - } - & - } - \cs_set_protected:Npn \acro_print_list_page:n ##1 + \use:x { - \bool_if:nT { \cs_if_exist_p:c { acro@##1@once } } - { \UseInstance {acro-page-number} { \l__acro_page_instance_tl } {##1} } - \tabularnewline + \exp_not:V \l__acro_list_before_tl + \exp_not:N \begin { \exp_not:V \l__acro_list_table_tl } + { \exp_not:V \l__acro_list_table_spec_tl } + \exp_not:n { \acro_list_items:nn {#1} {#2} } + \exp_not:N \end { \exp_not:V \l__acro_list_table_tl } + \exp_not:V \l__acro_list_after_tl } - \exp_args:Noo - \begin { \l__acro_list_table_tl } { \l__acro_list_table_spec_tl } - \acro_list_allow_items:nn {#2} {#3} - \exp_args:No - \end { \l__acro_list_table_tl } } -% extra-table-rev template: -\DeclareTemplateInterface {acro-list} {extra-table-rev} {3} +% -------------------------------------------------------------------------- +% declare new list styles: +\cs_new_protected:Npn \acro_declare_list_style:nnn #1#2#3 { - table : tokenlist = longtable , - table-spec : tokenlist = llp{\l__acro_table_width_dim}l + \DeclareInstance {acro-list} {#1} {#2} {#3} + \prop_put:Nnn \l__acro_list_styles_prop {#1} {#2} } -\DeclareTemplateCode {acro-list} {extra-table-rev} {3} - { - table = \l__acro_list_table_tl , - table-spec = \l__acro_list_table_spec_tl - } +% #1: name +% #2: template +% #3: settings +\NewDocumentCommand \DeclareAcroListStyle {mmm} + { \acro_declare_list_style:nnn {#1} {#2} {#3} } + +% set a list style +\cs_new_protected:Npn \acro_set_list_style:n #1 { - \AssignTemplateKeys - \acro_activate_hyperref_support: - \cs_set_eq:NN \acro_print_list_entry:nnn \use:nnn - \cs_set_protected:Npn \acro_print_list_short:nn ##1##2 + \prop_if_in:NnTF \l__acro_list_styles_prop {#1} + { \__acro_set_list_style:n {#1} } { - \acro_hyper_target:nn - {##1} - { \acro_acc_supp:nn {##1} { \acro_write_short:nn {##1} {##2} } } - & + \msg_warning:nnnn {acro} {unknown-list-style} {#1} {description} + \__acro_set_list_style:n {description} } - \cs_set_protected:Npn \acro_print_list_extra:n ##1 - { - \bool_if:NT \l__acro_capitalize_list_bool - { \bool_set_true:N \l__acro_first_upper_bool } - \acro_write_long:Vf \l__acro_long_format_tl - { - \prop_if_in:NnTF \l__acro_list_prop {##1} - { \prop_item:Nn \l__acro_list_prop {##1} } - { \prop_item:Nn \l__acro_long_prop {##1} } - } - \acro_cite_if:Nn \l__acro_citation_all_bool {##1} - & - } - \cs_set_protected:Npn \acro_print_list_long:n ##1 - { - \prop_get:NnNT \l__acro_extra_prop {##1} \l__acro_tmpa_tl - { - \UseInstance {acro-extra} { \l__acro_extra_instance_tl } - { \l__acro_tmpa_tl } - } - & - } - \cs_set_protected:Npn \acro_print_list_page:n ##1 - { - \bool_if:nT { \cs_if_exist_p:c { acro@##1@once } } - { \UseInstance {acro-page-number} { \l__acro_page_instance_tl } {##1} } - \tabularnewline - } - \exp_args:Noo \begin { \l__acro_list_table_tl } { \l__acro_list_table_spec_tl } - \acro_list_allow_items:nn {#2} {#3} - \exp_args:No \end { \l__acro_list_table_tl } } -% the different styles: -\DeclareInstance {acro-list} {list} - { list } +\cs_new_protected:Npn \__acro_set_list_style:n #1 + { + \tl_set:Nn \l__acro_list_instance_tl {#1} + \tl_set:Nx \l__acro_list_type_tl + { \prop_item:Nn \l__acro_list_styles_prop {#1} } + } + +% -------------------------------------------------------------------------- +% predefined list styles: +\DeclareAcroListStyle {description} {list} { } -\DeclareInstance {acro-list} {toc} - { list-of } + +\DeclareAcroListStyle {toc} {list-of} { } -\DeclareInstance {acro-list} {lof} - { list-of } + +\DeclareAcroListStyle {lof} {list-of} { style = lof } -\DeclareInstance {acro-list} {tabular} - { table } + +\DeclareAcroListStyle {tabular} {table} { table = tabular } -\DeclareInstance {acro-list} {longtable} - { table } - { table = longtable } -\DeclareInstance {acro-list} {extra-longtable} - { extra-table } + +\DeclareAcroListStyle {longtable} {table} { table = longtable } -\DeclareInstance {acro-list} {extra-tabular} - { extra-table } + +\DeclareAcroListStyle {extra-tabular} {extra-table} { table = tabular } -\DeclareInstance {acro-list} {extra-longtable-rev} - { extra-table-rev } + +\DeclareAcroListStyle {extra-longtable} {extra-table} { table = longtable } -\DeclareInstance {acro-list} {extra-tabular-rev} - { extra-table-rev } - { table = tabular } + +\DeclareAcroListStyle {extra-tabular-rev} {extra-table} + { + table = tabular , + reverse = true + } + +\DeclareAcroListStyle {extra-longtable-rev} {extra-table} + { + table = longtable , + reverse = true + } % -------------------------------------------------------------------------- % automatic typesetting, the internals of \ac: % #1: id + \cs_new_protected:Npn \acro_use:n #1 { % get the acronym and the plural settings: @@ -1511,10 +1521,11 @@ \acro_if_is_single:nTF {#1} { \acro_single:n {#1} } { - \UseInstance {acro-first} { \l__acro_first_instance_tl } + \acro_first_instance:VnVV + \l__acro_first_instance_tl {#1} - { \l__acro_short_tl } - { \l__acro_long_tl } + \l__acro_short_tl + \l__acro_long_tl } } } @@ -1531,10 +1542,11 @@ \acro_cite:n {#1} } {first} { - \UseInstance {acro-first} { \l__acro_first_instance_tl } + \acro_first_instance:VnVV + \l__acro_first_instance_tl {#1} - { \l__acro_short_tl } - { \l__acro_long_tl } + \l__acro_short_tl + \l__acro_long_tl } } { % other (e.g. short) @@ -2108,14 +2120,11 @@ \acro_is_used:n {#1} \acro_if_is_single:nT {#1} { \cs_set_eq:NN \acro_hyper_link:nn \use_ii:nn } - \use:x - { - \UseInstance {acro-first} - { \exp_not:V \l__acro_first_instance_tl } - { \exp_not:n {#1} } - { \exp_not:V \l__acro_short_tl } - { \exp_not:V \l__acro_long_tl } - } + \acro_first_instance:VnVV + \l__acro_first_instance_tl + {#1} + \l__acro_short_tl + \l__acro_long_tl } % output like the first time with own long version: @@ -2128,9 +2137,10 @@ \acro_is_used:n {#1} \acro_if_is_single:nT {#1} { \cs_set_eq:NN \acro_hyper_link:nn \use_ii:nn } - \UseInstance { acro-first } { \l__acro_first_instance_tl } + \acro_first_instance:VnVn + \l__acro_first_instance_tl {#1} - { \l__acro_short_tl } + \l__acro_short_tl {#2} } @@ -2504,7 +2514,7 @@ } % some user macros: -\cs_new_protected:Npn \acro_dot: { \aciftrailing {dot} {} {.} } +\cs_new_protected:Npn \acro_dot: { \aciftrailing {dot} {} {.\@} } \cs_new_eq:NN \acdot \acro_dot: \cs_new_protected:Npn \acro_space: @@ -2621,12 +2631,13 @@ \cs_new_protected:Npn #1 ##1##2 { \cs_set:Npn \__acro_tmp_command:n ####1 {##2} - \exp_args:NNnx #2 ##1 {sm} + \exp_args:NNnx #2 ##1 {sO{}m} { \acro_begin: \acro_reset_specials: - \acro_check_and_mark_if:nn {########1} {########2} - \exp_not:o { \__acro_tmp_command:n {####2} } + \keys_set:nn {acro} {########2} + \acro_check_and_mark_if:nn {########1} {########3} + \exp_not:o { \__acro_tmp_command:n {####3} } \acro_end: } } @@ -3324,13 +3335,6 @@ \tl_new:N \l__acro_included_classes_tl \tl_new:N \l__acro_excluded_classes_tl -\cs_new_protected:Npn \acro_use_list_instance:nn #1#2 - { - \UseInstance {acro-list} { \l__acro_list_instance_tl } - { \l__acro_list_type_tl } {#1} {#2} - } -\cs_generate_variant:Nn \acro_use_list_instance:nn { VV } - \keys_define:nn { acro / print-acronyms } { include-classes .tl_set:N = \l__acro_included_classes_tl , @@ -3356,11 +3360,13 @@ \iow_now:Nx \@auxout { \string \acro@print@list } \bool_if:NT \l__acro_sort_bool { \acro_sort_prop:N \l__acro_short_prop } - \UseInstance {acro-title} { \l__acro_list_title_tl } - { \l__acro_list_name_tl } + \acro_title_instance:VV + \l__acro_list_title_tl + \l__acro_list_name_tl \cs_if_exist:NTF \acro@printed@list { - \acro_use_list_instance:VV + \acro_list_instance:VVV + \l__acro_list_instance_tl \l__acro_included_classes_tl \l__acro_excluded_classes_tl } @@ -3412,6 +3418,19 @@ \DeclareTranslation { Portuguese } { acronym-next-pages } { ss. } \tl_set:Nn \l__acro_next_pages_tl { \,\GetTranslation {acronym-next-pages }\@ } +% -------------------------------------------------------------------------- +% allow for a configuration file: +\tl_const:Nn \c_acro_config_file_name_tl {acro} +\tl_const:Nn \c_acro_config_file_extension_tl {cfg} + +\file_if_exist:nT + { \c_acro_config_file_name_tl .\c_acro_config_file_extension_tl } + { + \@onefilewithoptions + {\c_acro_config_file_name_tl} [] [] + \c_acro_config_file_extension_tl + } + \tex_endinput:D % -------------------------------------------------------------------------- % HISTORY: @@ -3556,6 +3575,12 @@ - correct bug in the `plain' extra style - implemented `tooltip' property - remove \tl_to_lowercase:n +2015/10/03 v2.2 - fix https://bitbucket.org/cgnieder/acro/issue/52 + - fix typo in `list-of' object + - \DeclareAcroListStyle + - \DeclareAcroListHeading + - input `acro.cfg' if present + - all acro commands have an optional argument: \ac*[]{} % -------------------------------------------------------------------------- update => http://tex.stackexchange.com/questions/236362 |