diff options
author | Karl Berry <karl@freefriends.org> | 2013-01-18 23:26:48 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-01-18 23:26:48 +0000 |
commit | fb0e09783157c2c9f8e6899a25abc2442b8a77f6 (patch) | |
tree | 3ac58c5ecaa0f0e9130476ed1507cd8fdac116fc | |
parent | 9a3b24b6c40172a8e489ab6d7409303db574c826 (diff) |
acro (17jan13)
git-svn-id: svn://tug.org/texlive/trunk@28867 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/acro/README | 6 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/acro/acro_en.pdf | bin | 460959 -> 471647 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/acro/acro_en.tex | 617 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/acro/example_one.tex | 57 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/acro/example_two.tex | 72 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/acro/acro.sty | 649 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/acro/acro0.def | 168 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/acro/acro1.def | 337 |
8 files changed, 1528 insertions, 378 deletions
diff --git a/Master/texmf-dist/doc/latex/acro/README b/Master/texmf-dist/doc/latex/acro/README index 969a0cf1784..ae974b44b72 100644 --- a/Master/texmf-dist/doc/latex/acro/README +++ b/Master/texmf-dist/doc/latex/acro/README @@ -1,9 +1,9 @@ -------------------------------------------------------------------------- -the ACRO package v0.6a +the ACRO package v1.0 Typeset Acronyms -2013/01/02 +2013/01/16 -------------------------------------------------------------------------- Clemens Niederberger Web: https://bitbucket.org/cgnieder/acro/ @@ -24,7 +24,7 @@ This work has the LPPL maintenance status `maintained'. The Current Maintainer of this work is Clemens Niederberger. -------------------------------------------------------------------------- The acro package consists of the files - - acro.sty, acro_en.tex, acro_en.pdf, README + - acro.sty, acro0.def, acro1.def, acro_en.tex, acro_en.pdf, README -------------------------------------------------------------------------- If you have any ideas, questions, suggestions or bugs to report, please feel free to contact me. 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 0abda9252e3..fabcc34ad36 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 c021a4eff59..72c4fe55d40 100644 --- a/Master/texmf-dist/doc/latex/acro/acro_en.tex +++ b/Master/texmf-dist/doc/latex/acro/acro_en.tex @@ -27,7 +27,7 @@ % The Current Maintainer of this work is Clemens Niederberger. % -------------------------------------------------------------------------- % The acro package consists of the files -% - acro.sty, acro_en.tex, acro_en.pdf, README +% - acro.sty, acro0.def, acro1.def, acro_en.tex, acro_en.pdf, README % -------------------------------------------------------------------------- % If you have any ideas, questions, suggestions or bugs to report, please % feel free to contact me. @@ -40,7 +40,7 @@ % \documentclass[DIV10,toc=index,toc=bib,hyperfootnotes=false]{cnpkgdoc} \docsetup{ - pkg = {[single,macros,sort]acro} , + pkg = {[single,macros,accsupp]acro} , language = en , code-box = { backgroundcolor = gray!7!white , @@ -95,8 +95,8 @@ @package{acronym, title = {acronym -- An Acronym Environment for \LaTeXe}, author = {Tobias Oetiker}, - date = {2010-09-08}, - version = {1.36}, + date = {2012-10-29}, + version = {1.38}, url = {http://www.ctan.org/pkg/acronym} } @package{acroterm, @@ -109,8 +109,8 @@ @package{glossaries, title = {glossaries}, author = {Nicola L.C. Talbot}, - date = {2011-04-12}, - version = {3.01}, + date = {2012-11-18}, + version = {3.04}, url = {http://www.ctan.org/pkg/glossaries} } @package{nomencl, @@ -177,25 +177,85 @@ } \ExplSyntaxOff -\DeclareAcronym{cd}{cd}{Compact Disc} - \DeclareAcronymFormat{cd}{\scshape} -\DeclareAcronym{id}{id}{identification string} - \DeclareAcronymFormat{id}{\scshape} -\DeclareAcronym{jpg}{JPEG}[JPG]{Joint Photographic Experts Group} -\DeclareAcronym{la}{LA,}{Los Angeles,}[city] -\DeclareAcronym*{mp}{MP}{Member of Parliament,Members of Parliament} -\DeclareAcronym{nato}{nato}{North Atlantic Treaty Organization}{\textit{deutsch}: Organisation des Nordatlantikvertrags} - \DeclareAcronymFormat{nato}{\scshape} -\DeclareAcronym{ny}{NY,}{New York,}[city] -\DeclareAcronymCitation{ny}{NewYork} -\DeclareAcronym{ot}{ot}{Other Test} - \DeclareAcronymFormat{ot}{\scshape} -\DeclareAcronym{pdf}{pdf}{Portable Document Format} - \DeclareAcronymFormat{pdf}{\scshape} - \DeclareAcronymPDFString{pdf}{PDF} -\DeclareAcronym{sw}{SW}{Sammelwerk,e} -\DeclareAcronym{test}{ST}{Some Test} -\DeclareAcronym{texse}{\{TeX\}.SE}{\TeX\ StackExchange} +% declare acronyms +\DeclareAcronym{cd} + { + short = cd , + long = Compact Disc , + format = \scshape + } +\DeclareAcronym{id} + { + short = id , + long = identification string , + format = \scshape + } +\DeclareAcronym{jpg} + { + short = JPEG , + alt = JPG , + long = Joint Photographic Experts Group + } +\DeclareAcronym{la} + { + short = LA , + short-plural = , + long = Los Angeles, + long-plural = , + class = city + } +\DeclareAcronym{mp} + { + short = MP , + long = Member of Parliament , + long-plural-form = Members of Parliament + } +\DeclareAcronym{nato} + { + short = nato , + long = North Atlantic Treaty Organization , + extra = \emph{deutsch}: Organisation des Nordatlantikvertrags , + format = \scshape + } +\DeclareAcronym{ny} + { + short = NY , + short-plural = , + long = New York , + long-plural = , + class = city , + cite = NewYork + } +\DeclareAcronym{ot} + { + short = ot , + long = Other Test , + format = \scshape + } +\DeclareAcronym{pdf} + { + short = pdf , + long = Portable Document Format , + format = \scshape , + pdfstring = PDF , + accsupp = PDF + } +\DeclareAcronym{sw} + { + short = SW , + long = Sammelwerk , + long-plural = e + } +\DeclareAcronym{test} + { + short = ST , + long = Some Test + } +\DeclareAcronym{texse} + { + short = \{TeX\}.SE , + long = \TeX{} StackExchange + } \usepackage{imakeidx} \makeindex[columns=2,options={-sl \jobname.ist},intoc] @@ -215,6 +275,14 @@ \textcolor{black!75}{Changed in version~#1}}% \@esphack} \renewcommand*\cnpkgdoctriangle{} + +\AtBeginDocument{% + \ifdef\texorpdfstring{}{\let\texorpdfstring\@firstoftwo}% +} +\newrobustcmd\@versionstar{\raisebox{-.25em}{*}} +\newcommand\versionstar{\texorpdfstring{\@versionstar}{*}} + +\newcommand*\CTANlink[1]{\href{http://www.ctan.org/pkg/#1}{#1}} \makeatother \begin{document} @@ -224,8 +292,10 @@ 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.'' -\acro loads and needs the following packages: \paket{expl3}, -\paket{xparse}, \paket{xtemplate} and \paket{l3keys2e}. +\acro loads and needs the following packages: \paket*{expl3}\footnote{\CTANurl{l3kernel}}, +\paket*{xparse}, \paket*{xtemplate}, \paket*{l3keys2e}\footnote{All three part of +the \CTANlink{l3packages} bundle} and \paket*{translations}\footnote{Part of the +\CTANlink{exsheets} bundle.}. \section{About} \begin{zitat}[\cite{wikipedia}] @@ -234,7 +304,7 @@ terms of the \LaTeX{} Project Public License, version 1.3 or later or parts of words (as in Benelux and Ameslan). There is no universal agreement on the precise definition of the various terms nor on written usage. \end{zitat} -After \wikipedia\ told us what acronyms are and we won't confuse them with units +After \wikipedia{} told us what acronyms are and we won't confuse them with units or other kinds of abbreviations -- why would we need another package for them? There are several already: \paket{acronym}~\cite{acronym}, \paket{acromake}% ~\cite{acromake}, \paket{acroterm}~\cite{acroterm}, the abbreviations package @@ -247,8 +317,9 @@ new package. On the other hand \paket{acronym}, the best of the acronym specific packages, has one or two shortcomings and sometimes using \paket{glossaries} seems a bit of an overkill (or simply inconvenient as one has to run \code{makeglossaries}, -\code{makeindex} or \code{xindy}, then). So \acro stands somewhere in between -(but much closer to \paket{acronym}). +\code{makeindex} or \code{xindy}, then\footnote{Rumour has it there is going to +be a version that can be used without running an external program}). So \acro +stands somewhere in between (but closer to \paket{acronym}). The main reason for the existance of \acro is a question on \acs{texse}% \footnote{\url{http://tex.stackexchange.com/q/59449/5049}} which intrigued @@ -258,44 +329,111 @@ me and in consequence led to \acro and it's option \key{single}. some macros have the same name and meaning\footnote{\emph{Not} in the sense of \code{\textbackslash\textcolor{code}{meaning}}!}. +Please take a minute to think and decide which package will suit your needs +best. Are you planning to add a glossary to your book? You should probably go +with \paket{glossaries}, then. Are you planning to add a nomenclature? You +may want to choose \paket{nomencl} and so on\ldots + + +\section{Updating from Version~0.\versionstar} +Version~1.0 introduces a major syntax change. In order to keep documents +using a prior version compilable \acro introduces the option \key{version}{0}. +It provides the acronym defining commands with the old syntax and also all the +additional commands like \cmd{DeclareAcronymFormat} that have been dropped in +version~1.0. Also the old syntax of \cmd{printacronyms} is restored. +Versions~0.\versionstar{} also set labels when an acronym was used the first time, +version~1.0 doesn't do that any more. \key{version}{0} sets them as expected. + +Note that \key{version}{0} \emph{does not and will not} support new features of +any kind. + +With version~1.0 acronyms are declared with a key/value syntax similar to the +way in package \paket{glossaries} glossary entries are defined. This was made +for a good reason: in the beginning the old \cmd*{DeclareAcronym} already had +lots of arguments that were hard to remember. Every new feature needed to +introduce further commands so that in version~0.6 there have been \emph{four} +different commands already. All this isn't necessary any more and there is only +one command with only two arguments. + \section{Basics}\secidx{Basics} \subsection{Creating New Acronyms}\secidx[new acronyms]{Basics} -Acronyms are created with the command \cmd{DeclareAcronym} that can only be used -in the preamble. +\noindent\changedversion{1.0}Acronyms are created with the command +\cmd{DeclareAcronym} that can only be used in the preamble. \begin{beschreibung} - \Befehl{DeclareAcronym}*{<id>}\ma{<short>,<pl>}\oa{<alt.>}\ma{<long>,<pl>}\ma{<extra>}\oa{<class>} - \verb+% can be used only in preamble+ - \Befehl{DeclareAcronymFormat}{<id>}\ma{<format>} \verb+% can be used only in preamble+ - \Befehl{DeclareAcronymCitation}{<id>}\oa{<pre>}\oa{<post>}\ma{<cite keys>} - \verb+% can be used only in preamble+ - \Befehl{DeclareAcronymPDFString}{<id>}\ma{<pdf entry>,<plural ending>} - \verb+% can be used only in preamble+ + \Befehl{DeclareAcronym}{<id>}\ma{<list of keys>} \end{beschreibung} -Although \cmd{DeclareAcronym} has quite a number of arguments. In the simplest -case you'll only need three: +This command understands a number of keys which are listed below. Some of them +are not described immediately but at appropriate places in the documentation. +\begin{beschreibung} + \Option{short}{<text>}\newline + the short form of the acronym. + \Option{long}{<text>}\newline + the long form of the acronym. + \Option{short-plural}{<text>}\Default{s} + the plural ending appended to the short form. + \Option{long-plural}{<text>}\Default{s} + the plural ending appended to the long form. + \Option{long-plural-form}{<text>}\newline + plural long form of the acronym; replaces the long form when used instead of + appending the plural ending. + \Option{alt}{<text>}\newline + alternative short form. + \Option{extra}{<text>}\newline + extra information to be added in the list of acronyms. + \Option{sort}{<text>}\newline + if used the acronym will be sorted according to this key instead of its \acs{id}. + \Option{class}{<text>}\newline + the class the acronym belongs to. + \Option{cite}{[<prenote>][<postnote>]\{citation keys\}}\newline + a citation that is printed to the acronym according to an option explained later. + \Option{format}{<\TeX{} code>}\newline + the format used for the short form of the acronym. + \Option{pdfstring}{<text>/<plural ending>}\newline + used as \acs{pdf} string replacement in bookmarks when used together with the + \paket*{hyperref} package. The appended plural ending is optional. If you + leave it (\emph{and} the \code{/}) the default ending is used. + \Option{accsupp}{<text>}\newline + sets the \code{ActualText} key as presented by the \paket*{accsupp} package + for the acronym. +\end{beschreibung} + +In its simplest form an acronym needs a short and a long form. Please note that +both keys \emph{must} be set and that the \key{short} key \emph{must} always be +the \emph{first} key that is set. \begin{beispiel}[code only] - % preamble - \DeclareAcronym{test}{ST}{Some Test} + % preamble: + \DeclareAcronym{test}{ + short = ST , + long = Some Test + } \end{beispiel} This creates the acronym ``\acs{test}'' with the \acs{id} ``test'' and the long -form ``\acl{test}.'' The other arguments will be described later in this document. +form ``\acl{test}.'' -\cmd{DeclareAcronymFormat} lets you assign a special format to an acronym. Maybe -small caps: +The \key{format} key allows you to choose a specific format for the short form of +an acronym: \begin{beispiel}[code only] % preamble: - \DeclareAcronym{ot}{ot}{Other Test} - \DeclareAcronymFormat{ot}{\scshape} + \DeclareAcronym{ot}{ + short = ot , + long = Other Test , + format = \scshape + } \end{beispiel} The short form now looks like this: \acs{ot}. -With \cmd{DeclareAcronymCitation} you can add a key as used in \cmd*{cite} that -is added to the first or every appearance of the acronym (depending on an option -that is described later). +The \key{cite} key needs a bit explaining. It expects arguments like the standard +\cmd*{cite} command, i.e., two optional arguments setting the \code{<prenote>} +and \code{<postnote>} and one mandatory argument setting the citation key. \begin{beispiel}[code only] % preamble: - \DeclareAcronym{ny}{NY,}{New York,} - \DeclareAcronymCitation{ny}{NewYork} + \DeclareAcronym{ny}{ + short = NY , + short-plural = , + long = New York , + long-plural = , + cite = {NewYork} + } % bib file for use with biber/biblatex: @online{NewYork, author = {Wikipedia}, @@ -311,29 +449,39 @@ of course depends on the citation style you're using.}: \acf{ny}. \subsection{Using the Acronyms -- the Commands}\secidx[using acronyms]{Basics} Acronyms are used with with one of the following commands: \begin{beschreibung} - \befehl{ac}*{<id>} basic command; the first output is different from subsequent - ones. - \befehl{Ac}*{<id>} same as \cmd{ac} but capitalizes the first letter of the - long form. - \befehl{acs}*{<id>} \h{s}hort form; the actual acronym. - \befehl{acl}*{<id>} \h{l}ong form; the meaning of the acronym. - \befehl{Acl}*{<id>} same as \cmd{acl} but capitalizes first letter. - \befehl{aca}*{<id>} \h{a}lternative short form as specified in the \oa{<short>} - argument of \cmd{DeclareAcronym}; if it hasn't been specified this is - identical to \cmd{acs}. - \befehl{acf}*{<id>} first form; output like the first time \cmd{ac} is output. - \befehl{Acf}*{<id>} same as \cmd{acf} but capitalizes first letter of the long - form. - \befehl{acp}*{<id>} \h{p}lural form of \cmd{ac}; - \befehl{Acp}*{<id>} same as \cmd{acp} but capitalizes first letter of the long - form. - \befehl{acsp}*{<id>} plural form of \cmd{acs}; - \befehl{aclp}*{<id>} plural form of \cmd{acl}; - \befehl{Aclp}*{<id>} same as \cmd{aclp} but capitalizes first letter. - \befehl{acap}*{<id>} plural form of \cmd{aca}; - \befehl{acfp}*{<id>} plural form of \cmd{acf}; - \befehl{Acfp}*{<id>} same as \cmd{acfp} but capitalizes first letter of the - long form. + \Befehl{ac}*{<id>}\newline + basic command; the first output is different from subsequent ones. + \Befehl{Ac}*{<id>}\newline + same as \cmd{ac} but capitalizes the first letter of the long form. + \Befehl{acs}*{<id>}\newline + \h{s}hort form; the actual acronym. + \Befehl{acl}*{<id>}\newline + \h{l}ong form; the meaning of the acronym. + \Befehl{Acl}*{<id>}\newline + same as \cmd{acl} but capitalizes first letter. + \Befehl{aca}*{<id>}\newline + \h{a}lternative short form as specified in the \key{alt} key of + \cmd{DeclareAcronym}; if it hasn't been specified this is identical to \cmd{acs}. + \Befehl{acf}*{<id>}\newline + first form; output like the first time \cmd{ac} is output. + \Befehl{Acf}*{<id>}\newline + same as \cmd{acf} but capitalizes first letter of the long form. + \Befehl{acp}*{<id>}\newline + \h{p}lural form of \cmd{ac}; + \Befehl{Acp}*{<id>}\newline + same as \cmd{acp} but capitalizes first letter of the long form. + \Befehl{acsp}*{<id>}\newline + plural form of \cmd{acs}; + \Befehl{aclp}*{<id>}\newline + plural form of \cmd{acl}; + \Befehl{Aclp}*{<id>}\newline + same as \cmd{aclp} but capitalizes first letter. + \Befehl{acap}*{<id>}\newline + plural form of \cmd{aca}; + \Befehl{acfp}*{<id>}\newline + plural form of \cmd{acf}; + \Befehl{Acfp}*{<id>}\newline + same as \cmd{acfp} but capitalizes first letter of the long form. \end{beschreibung} If an acronym is used the first time with \cmd{ac} its output is different from subsequent uses. To be clear on this: the first time! If the acronym has been @@ -345,8 +493,12 @@ used. This proves useful if an acronym is typeset in a section title, for exampl since then the appearance in the table of contents won't mark it as used. \begin{beispiel} - % preamble: \DeclareAcronym{cd}{cd}{Compact Disc} - % \DeclareAcronymFormat{cd}{\scshape} + % preamble: + % \DeclareAcronym{cd}{ + % short = cd , + % long = Compact Disc , + % format = \scshape + % } first time: \ac{cd} \\ second time: \ac{cd} \\ short: \acs{cd} \\ @@ -361,25 +513,45 @@ since then the appearance in the table of contents won't mark it as used. If an acronym is defined in the standard way \acro uses an `s' that's appended to both the short and the long form when one of the plural commands is used. However, that is not always the best solution. For one thing not all acronyms may have a -plural form. Second, the plural form especially of the long forms may be fomed +plural form. Second, the plural form especially of the long forms may be formed differently. And third, other languages can have other plural endings. -For this reason \cmd{DeclareAcronym} provides additional arguments: +For these reasons \cmd{DeclareAcronym} can get the following keys: \begin{beschreibung} - \Befehl{DeclareAcronym}{<id>}\ma{<short>,<plural ending>}\ma{<long>,<plural ending>} - \Befehl{DeclareAcronym}*{<id>}\ma{<short>,<plural ending>}\ma{<long>,<plural form>} + \Option{short-plural}{<text>} + \Option{long-plural}{<text>} + \Option{long-plural-form}{<text>} \end{beschreibung} -These arguments are optional. If they're not used, the default setting is `s'. -If you use the starred version the long form will be replaced by the specified -plural form when necessary. A given short plural will still be appended. +These keys are optional. If they're not used, the default setting is `s'. +If you use \key{long-plural-form} the long form will be replaced by the specified +plural form when necessary. +Suppose we define the following acronyms: +\begin{beispiel}[code only] + \DeclareAcronym{cd}{ + short = cd , + long = Compact Disc , + format = \scshape + } + \DeclareAcronym{ny}{ + short = NY , + short-plural = , + long = New York , + long-plural = + } + \DeclareAcronym{sw}{ + short = SW , + long = Sammelwerk , + long-plural = e + } + \DeclareAcronym{mp}{ + short = MP , + long = Member of Parliament , + long-plural-form = Members of Parliament + } +\end{beispiel} +These acronyms now have the following plural appearances: \begin{beispiel} - % preamble: - % \DeclareAcronym{cd}{\textsc{cd}}{Compact Disc} - % \DeclareAcronymFormat{cd}{\scshape} - % \DeclareAcronym{ny}{NY,}{New York,} - % \DeclareAcronym{sw}{SW}{Sammelwerk,e} - % \DeclareAcronym*{mp}{MP}{Member of Parliament,Members of Parliament} \acsp{cd}, \aclp{cd} \\ \acsp{ny}, \aclp{ny} \\ \acsp{sw}, \aclp{sw} \\ @@ -388,12 +560,17 @@ plural form when necessary. A given short plural will still be appended. \subsection{Alternative Short Forms}\secidx[alternative forms]{Basics} For some acronyms it might be useful to have alternative forms. For this -\cmd{DeclareAcronym} has another optional argument: +\cmd{DeclareAcronym} has another key: \begin{beschreibung} - \Befehl{DeclareAcronym}{<id>}\ma{<short>}\oa{<alternative>}\ma{<long>} + \Option{alt}{<text>} \end{beschreibung} \begin{beispiel} - % preamble \DeclareAcronym{jpg}{JPEG}[JPG]{Joint Photographic Experts Group} + % preamble: + % \DeclareAcronym{jpg}{ + % short = JPEG , + % alt = JPG , + % long = Joint Photographic Experts Group + % } default: \acs{jpg} \\ alt.: \aca{jpg} \end{beispiel} @@ -403,17 +580,21 @@ is formatted in the same way. \subsection{Extra Information for the List Entry}\secidx[extra information]{Basics} Of course you can print a list of acronyms where their meaning is explained. Sometimes it can be useful to add additional information there. This is done with -another optional argument to \cmd{DeclareAcronym}: +another key to \cmd{DeclareAcronym}: \begin{beschreibung} - \Befehl{DeclareAcronym}{<id>}\ma{<short>}\ma{<long>}\ma{<extra>} + \Option{extra}{<text>} \end{beschreibung} These information will only be displayed in the list. See section~\ref{sec:print_lists} for the impact of the following example. \begin{beispiel} % preamble: - % \DeclareAcronym{nato}{nato}{North Atlantic Treaty Organization}{\textit{deutsch}: Organisation des Nordatlantikvertrags} - % \DeclareAcronymFormat{nato}{\scshape} + % \DeclareAcronym{nato}{ + % short = nato , + % long = North Atlantic Treaty Organization , + % extra = \textit{deutsch}: Organisation des Nordatlantikvertrags , + % format = \scshape + % } The \ac{nato} is an intergovernmental military alliance based on the North Atlantic Treaty which was signed on 4~April 1949. \ac{nato} headquarters are in Brussels, Belgium, one of the 28 member states @@ -426,14 +607,27 @@ for the impact of the following example. \subsection{Using Classes}\secidx[classes]{Additional Commands} 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 \cmd{DeclareAcronym} has an optional argument: +For this \cmd{DeclareAcronym} has an additional key: \begin{beschreibung} - \Befehl{DeclareAcronym}{<id>}\ma{<short>}\ma{<long>}\oa{<class>} + \Option{class}{<text>} \end{beschreibung} \begin{beispiel} % preamble: - % \DeclareAcronym{la}{LA,}{Los Angeles,}[city] - % \DeclareAcronym{ny}{NY,}{New York,}[city] + % \DeclareAcronym{la}{ + % short = LA , + % short-plural = , + % long = Los Angeles , + % long-plural = , + % class = city + % } + % \DeclareAcronym{ny}{ + % short = NY , + % short-plural = , + % long = New York , + % long-plural = , + % class = city , + % cite = NewYork + % } \acl{la} (\acs{la}) \\ \acl{ny} (\acs{ny}) \end{beispiel} @@ -451,19 +645,13 @@ for the first time you can call one of these commands: \begin{beispiel} \acreset{ny}\ac{ny} \end{beispiel} -Beware that both commands act \emph{globally}! There is also one command that -effectively is the opposite of \cmd{acreset}, i.e., it marks an acronym as used: +Beware that both commands act \emph{globally}! There are also commands that +effectively do the opposite of \cmd{acreset}, i.e., mark acronyms as used: \begin{beschreibung} \Befehl{acuse}{<comma separated list of ids>}\sinceversion{0.5} \Befehl{acuseall}\sinceversion{0.6a} \end{beschreibung} -\subsection{Labels}\secidx[labels]{Additional Commands} -The first usage of an acronym sets a label \verb+\label{ac:<id>}+, regardless -which command has been used to typeset it. This label is used to create the page -numbers in the list (see section~\ref{sec:print_lists} for details) but can also -be used for other references if needed. - \subsection{\cmd{ac} and Friends in \acs*{pdf} Bookmarks} \noindent\sinceversion{0.5}\acro's commands usually are not expandable which means they'd leave unallowed tokens in \acs{pdf} bookmarks. \paket{hyperref} @@ -477,44 +665,76 @@ would do (or \cmd{acsp} for plural forms). These text strings both can accessed manually and can be modified to an output reserved for \acs{pdf} bookmarks. \begin{beschreibung} - \befehl{acpdfstring}{<id>} access the text string used in \acs{pdf} bookmarks. - \befehl{acpdfstringplural}{<id>} access the plural form of the text string used - in \acs{pdf} bookmarks. - \Befehl{DeclareAcronymPDFString}{<id>}\ma{<pdf entry>,<plural ending>} \cnpkgdocarrow\ - declare a custom text string for \acs{pdf} bookmarks. + \Befehl{acpdfstring}{<id>}\newline + access the text string used in \acs{pdf} bookmarks. + \Befehl{acpdfstringplural}{<id>}\newline + access the plural form of the text string used in \acs{pdf} bookmarks. + \Option{pdfstring}{<pdfstring>/<plural ending>}\newline + Key for \cmd{DeclareAcronym} to declare a custom text string for \acs{pdf} + bookmarks. The plural ending can be set optionally. + \Option{accsupp}{<text>}\newline + \sinceversion{1.0}Key for \cmd{DeclareAcronym} to set the \code{ActualText} + property of \cmd*{BeginAccSupp} (see \paket{accsupp}'s documentation for details) + to be used for an acronym. It only has an effect when the package option \key{accsupp} + is used, too. \end{beschreibung} For example the \acs{pdf} acronym used in the title for this section is defined as follows: \begin{beispiel}[code only] - \DeclareAcronym{pdf}{pdf}{Portable Document File} - \DeclareAcronymFormat{pdf}{\scshape} - \DeclareAcronymPDFString{pdf}{PDF} + \DeclareAcronym{pdf} + { + short = pdf , + long = Portable Document Format , + format = \scshape , + pdfstring = PDF , + accsupp = PDF + } \end{beispiel} +This also demonstrates the \key{accsupp} key. For this to work you need to use +the \emph{package option} \key{accsupp}, too, which will load the package +\paket{accsupp}. Then the key \key{accsupp} will set the \code{ActualText} +property of \cmd*{BeginAccSupp}. Please refer to \paket{accsupp}'s documentation +for details. To see its effect copy \ac{pdf} and paste it into a text file. You +should get uppercase letters instead of lowercase ones. \secidx*{Additional Commands} \section{Printing the List}\label{sec:print_lists}\secidx{Printing the List} -Printing the whole list of acronyms is easy: just place \cmd{printacronyms} -wherever you want the list to be. +\noindent\changedversion{1.0}Printing the whole list of acronyms is easy: just +place \cmd{printacronyms} wherever you want the list to be. \begin{beschreibung} - \Befehl{printacronyms}{<list of classes>}\oa{<excluded classes>} \cnpkgdocarrow\ - the first \emph{optional} (!) argument \ma{<list of classes>} takes a comma-separated - list of the classes of acronyms that should be in the list. If the argument is - left out, \emph{all} acronyms are printed. In the optional argument \oa{<excluded - classes>} classes can be specified that shall not be included into the list. + \Befehl{printacronyms}[<options>] \end{beschreibung} -\begin{beispiel}[below] - \acsetup{hyperref=false,extra-style=comma} - \printacronyms[city] - \acsetup{list-name=City Acronyms} - \printacronyms{city} +The commands takes a few options, namely the following ones: +\begin{beschreibung} + \Option{include-classes}{<list of classes>}\newline + takes a comma-separated list of the classes of acronyms that should be in the + list. + \Option{exclude-classes}{<list of classes>}\newline + takes a comma-separated list of the classes of acronyms that should \emph{not} + be in the list. + \Option{name}{<name of the list>}\newline + sets the name for the list. + \Option{header}{<sectioning command without leading backslash>}\Default{section*} + sets the sectioning command for the header of the list. +\end{beschreibung} +\begin{beispiel}[code only] + \acsetup{extra-style=comma} + \printacronyms[exclude-classes=city] + + \printacronyms[include-classes=city,name={City Acronyms}] \end{beispiel} +\acsetup{extra-style=comma} +\printacronyms[exclude-classes=city] + +\printacronyms[include-classes=city,name={City Acronyms}] + You can see that the default layout is a \code{description} list with a \code{section*} title. Both can be changed, see section~\ref{sec:customization}. -The command \cmd{printacronyms} needs two \LaTeX\ runs. This is a precaution to +The command \cmd{printacronyms} needs two \LaTeX{} runs. This is a precaution to avoid error messages with a possibly empty list. But since almost all documents need at least two runs and often are compiled much more often than that, this fact shouldn't cause too much inconvenience. @@ -526,6 +746,10 @@ There are a few options which change the general behaviour of \acro. \default{Underlined} values are used if no value is given. \begin{beschreibung} %% + \Option{version}{0|1}\Default{1} + Provide backwards compatibility for documents set with \acro in a version + prior to v1.0. + %% \Option{single}{\default{true}|false}\Default{false} If set to \code{true} an acronym that's used only once '(with \cmd{ac}) in a document will only print the long form and will not be printed in the list. @@ -534,6 +758,13 @@ There are a few options which change the general behaviour of \acro. If set to \code{true} the short forms of the acronyms will be linked to their list entry. %% + \Option{record-pages}{\default{true}|false}\Default{true} + Since \acro can handle arabic, roman and Roman page numbers but \emph{not} + any other kind of numbering this option enables to turn the page number + recording of for these cases as it would lead to errors else. This affects + the whole document and can only be set in the preamble! It means you cannot + have page numbers in the list of acronyms in this case. + %% \Option{only-used}{\default{true}|false}\Default{true} This option is \code{true} as default. It means that only acronyms that are actually used in the document are printed in the list. If \code{false}, all @@ -553,14 +784,14 @@ There are a few options which change the general behaviour of \acro. If set to \code{true} and the option \key{macros}{true} is in effect then already existing macros will be overwritten. %% - \Option{sort}{\default{true}|false}\Default{false} + \Option{sort}{\default{true}|false}\Default{true} If set to \code{true} the acronym list will be sorted automatically. The entries are sorted by their \acs{id} ignoring upper and lower case. This option needs the experimental package \paket*{l3sort} (from the \paket{l3experimental} bundle) and can only be set in the preamble. %% \Option{cite}{\default{all}|first|none}\Default{first} - This option decides whether citations that are added vie \cmd{DeclareAcronymCitation} + This option decides whether citations that are added via \cmd{DeclareAcronymCitation} are added to each first, every or no appearance of an acronym. %% \Option{cite-cmd}{<cmd>}\Default{\cmd*{cite}} @@ -573,6 +804,11 @@ There are a few options which change the general behaviour of \acro. citation or maybe not (e.g.\ \cmd*{footcite}\ldots). This option allows you to set this. Actually it can be used to place arbitrary code right before the citation.\catcode`\_=11 + %% + \Option{accsupp}{\default{true}|false}\Default{false} + \sinceversion{1.0}Activates the access support as provided by the + \paket{accsupp} package. + %% \Option{uc-cmd}{<cmd>}\Default{\cmd*{acro_first_upper_case:n}} The command that is used to capitalize the first word in the \cmd{Ac} and the like commands. You can change it to another one like for example @@ -583,8 +819,8 @@ There are a few options which change the general behaviour of \acro. All options of this and the following sections can be set up either as package options or via the setup command: \begin{beschreibung} - \Befehl{acsetup}{<options>} set up \acro anywhere in the document. Or separate - package loading from setup. + \Befehl{acsetup}{<options>}\newline + set up \acro anywhere in the document. Or separate package loading from setup. \end{beschreibung} \begin{beispiel} @@ -643,11 +879,36 @@ possible output forms of the acronyms. \begin{beschreibung} %% \Option{page-ref}{none|plain|comma|paren}\Default{none} - The style with which the page number of the first appearance of the acronym - in the text is displayed. + If this option is set to a value other than \code{none} the page numbers of + the an acronym appeared on are printed in the list. Please note that this + is an experimental feature and might fail in quite a number of cases. If you + notice anything please send me an email! + %% + \Option{page-name}{<page name>}\Default{p.\cmd*{@}\cmd*{,}} + The ``name'' of the page label. This is automatically translated to the + active language. However for the time being there are many translations + missing, yet. Please notify me if you find your language missing. + \Option{pages-name}{<page name plural>}\Default{pp.\cmd*{@}\cmd*{,}} + \sinceversion{1.0}The ``name'' of the page label when there are more than one + page. This is automatically translated to the active language. However for the + time being there are many translations missing, yet. Please notify me if you + find your language missing. %% - \Option{page-name}{<page name>}\Default{p.} - The ``name'' of the page label. + \Option{page-ranges}{\default{true}|false}\Default{true} + \sinceversion{1.0}If set to \code{false} ranges will be set by appending + \code{f} or \code{ff}, respectively. + %% + \Option{next-page}{<text>}\Default{\cmd*{,}f.\cmd*{@}} + \sinceversion{1.0}Appended to a page number when \key{page-ranges} is set to + \code{false} and the range is only 2 pages long. This is automatically + translated to the active language. However, for the time being there are many + translations missing, yet. Please notify me if you find your language missing. + %% + \Option{next-pages}{<text>}\Default{\cmd*{,}ff.\cmd*{@}} + \sinceversion{1.0}Appended to a page number when \key{page-ranges} is set to + \code{false} and the range is more than 2 pages long. This is automatically + translated to the active language. However, for the time being there are many + translations missing, yet. Please notify me if you find your language missing. %% \Option{list-type}{table|<list>}\Default{description} This option let's you choose how the list is printed. \code{<list>} can be any @@ -666,7 +927,10 @@ possible output forms of the acronyms. The header type of the list.\Default{section*} %% \Option{list-name}{<list name>}\Default{Acronyms} - The name of the list. This is what's written in the list-header. + The name of the list. This is what's written in the list-header. This is + automatically translated to the active language. However, for the time being + there are many translations missing, yet. Please notify me if you find your + language missing. %% \Option{list-table-width}\Default{.7\cmd{linewidth}} This has only an effect if you chose \key{list-type}{table}. The second column @@ -679,7 +943,7 @@ possible output forms of the acronyms. If you for example have loaded \paket{enumitem} you can define a custom list for the acronym list: -\begin{beispiel} +\begin{beispiel}[code only] % preamble: % \usepackage{enumitem} \newlist{acronyms}{description}{1} @@ -688,8 +952,38 @@ the acronym list: \acsetup{list-type=acronyms,hyperref=false,extra-style=comma} \printacronyms \end{beispiel} +\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 + +\section{About Page Ranges}\secidx{About Page Ranges} +If you enable the \key{page-ref} option \acro adds page numbers to the list of +acronyms. In version~0.\versionstar{} it would add a page reference for an acronym +in the list of acronyms that used \cmd*{pageref} to refer to the first appearance +of an acronym. This is retained using \key{version}{0}. Version~1.0 uses a +different approach that doesn't use a label but instead will list \emph{all} +pages an acronym appeared on. With \paket{hyperref} the pages are referenced +using \cmd*{hyperpage}. + +There are some options that control how this list will be typeset, e.g., +\key{page-ranges}, \key{next-pages} or the option \key{page-ref} itself. It is +important to mention that the page list will always take two compilation runs +until changes in the options or the actual page numbers affect it. This is due to +the fact that the updated sequence is first written to the \code{aux} file and +only read in during the next run. + +There is another important fact: \acro can only handle arabic and lowercase and +uppercase roman page numbering. If you happen to choose a different numbering +style you either have to use the package option \key{record-pages}{false} which +means you will have to pass on page numbers in the list of acronyms, or you need +to make sure that you only use the \emph{starred} versions of the \cmd{ac} commands +on these pages so acronyms don't count as used there! \secidx*{Customization} +\secidx*{About Page Ranges} + \section{hyperref Support}\secidx{\paket{hyperref} support}[hyperref Support] The option \key{hyperref}{true} adds internal links from all short (or alternative) forms to their respective list entries. Of course this only works if you have @@ -699,10 +993,30 @@ in loads of \paket{hyperref} warnings. Also printing several lists can result in warnings if don't clearly separate the lists into different classes. If an acronym appears in more than one list there will also be more than one hypertarget for this acronym. + +Using \paket{hyperref} will also add \cmd{hyperpage} to the page numbers in the +list (provided they are displayed in the style chosen). Like with an index the +references will thus not point to the acronyms directly but to the page they're +on. \secidx*{\paket{hyperref} support}[hyperref Support] \appendix +\section{Commands provided in version~0.\versionstar} +Prior to version~1.0 the following commands were available. They are still +provided if you set the option \key{version}{0}. They will be mentioned here +shortly but they won't be explained any more. If you'd like a more thorough +description ask me for the documentation to version~0.6a. +\begin{beschreibung} + \Befehl{DeclareAcronym}*{<id>}\ma{<short>,<pl>}\oa{<alt.>}\ma{<long>,<pl>}\ma{<extra>}\oa{<class>} + \newline\verb+% can be used only in preamble+ + \Befehl{DeclareAcronymFormat}{<id>}\ma{<format>} \verb+% can be used only in preamble+ + \Befehl{DeclareAcronymCitation}{<id>}\oa{<pre>}\oa{<post>}\ma{<cite keys>} + \newline\verb+% can be used only in preamble+ + \Befehl{DeclareAcronymPDFString}{<id>}\ma{<pdf entry>,<plural ending>} + \newline\verb+% can be used only in preamble+ +\end{beschreibung} + \section{All Acronyms Used in this Documentation}\label{sec:documentation_acronyms} \begin{beispiel}[code only] \acsetup{ @@ -710,30 +1024,29 @@ acronym. list-style = longtable, list-header = subsection*, extra-style = comma, - page-ref = comma, - list-name = All Acronyms} - \printacronyms + page-ref = comma + } + \printacronyms[name=All Acronyms] \end{beispiel} \acsetup{ list-type = table, list-style = longtable, list-header = subsection*, extra-style = comma, - page-ref = comma, - list-name = All Acronyms} -\printacronyms + page-ref = comma +} +\printacronyms[name=All Acronyms] \begin{beispiel}[code only] \acsetup{ list-type = table, list-style = longtable, list-header = subsection*, - page-ref = comma, - list-name = City-Acronyms} - \printacronyms{city} + page-ref = comma + } + \printacronyms[include-classes=city,name=City Acronyms] \end{beispiel} -\acsetup{list-name=City-Acronyms} -\printacronyms{city} +\printacronyms[include-classes=city,name=City Acronyms] {\RaggedRight\EmbracOff \printbibliography} diff --git a/Master/texmf-dist/doc/latex/acro/example_one.tex b/Master/texmf-dist/doc/latex/acro/example_one.tex index e2bff36d42c..ea775ba86c3 100644 --- a/Master/texmf-dist/doc/latex/acro/example_one.tex +++ b/Master/texmf-dist/doc/latex/acro/example_one.tex @@ -3,6 +3,7 @@ \documentclass{scrartcl} \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} +\usepackage[ngerman]{babel} \usepackage{acro} \acsetup{ page-ref = paren,% Seitennummer in Klammern @@ -13,16 +14,50 @@ \usepackage{longtable,siunitx} -\DeclareAcronym{ecm}{ECM} {Electro Chemical Machining}{Elektrochemisches Abtragen} -\DeclareAcronym{adc}{ADC} {Analog-to-Digital-Converter} -\DeclareAcronym{edm}{EDM} {Electro Discharge Machining} -\DeclareAcronym{ecdm}{ECDM}{Electro Chemical Discharge Machining}{Kombination aus \acs{ecm} und \acs{edm}} +\DeclareAcronym{ecm}{ + short = ECM , + long = Electro Chemical Machining , + extra = Elektrochemisches Abtragen +} +\DeclareAcronym{adc}{ + short = ADC , + long = Analog-to-Digital-Converter +} +\DeclareAcronym{edm}{ + short = EDM , + long = Electro Discharge Machining +} +\DeclareAcronym{ecdm}{ + short = ECDM , + long = Electro Chemical Discharge Machining , + extra = Kombination aus \acs{ecm} und \acs{edm} +} % "Acronyme" (tatsächlich physikalische Größen) einer speziellen Klasse: -\DeclareAcronym{f}{\ensuremath{f}}{Frequenz}{\si{\hertz}}[physics] -\DeclareAcronym{A}{\ensuremath{A}}{Fläche}{\si{\metre^2}}[physics] -\DeclareAcronym{C}{\ensuremath{C}}{Kapazität}{\si{\farad}}[physics] -\DeclareAcronym{F}{\ensuremath{F}}{Kraft}{\si{\newton}}[physics] +\DeclareAcronym{f}{ + short = \ensuremath{f} , + long = Frequenz , + extra = \si{\hertz} , + class = physics +} +\DeclareAcronym{A}{ + short = \ensuremath{A} , + long = Fläche , + extra = \si{\metre^2} , + class = physics +} +\DeclareAcronym{C}{ + short = \ensuremath{C} , + long = Kapazität , + extra = \si{\farad} , + class = physics +} +\DeclareAcronym{F}{ + short = \ensuremath{F} , + long = Kraft , + extra = \si{\newton} , + class = physics +} \begin{document} @@ -31,16 +66,14 @@ erstes Mal: \ac{ecm} zweites Mal: \ac{ecm} % alle außer der Klasse 'physics' auflisten: -\acsetup{list-name=Abkürzungsverzeichnis} -\printacronyms[physics] +\printacronyms[exclude-classes=physics, name=Abkürzungsverzeichnis] % nur die Klasse 'physics' auflisten: \acsetup{ - list-name = Formelverzeichnis, list-type = table, list-style = extra-longtable-rev, extra-style = plain } -\printacronyms{physics} +\printacronyms[include-classes=physics, name=Formelverzeichnis] \end{document}
\ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/acro/example_two.tex b/Master/texmf-dist/doc/latex/acro/example_two.tex index 75b009e33d0..f75738b45f4 100644 --- a/Master/texmf-dist/doc/latex/acro/example_two.tex +++ b/Master/texmf-dist/doc/latex/acro/example_two.tex @@ -3,21 +3,71 @@ % this file is an adapted version of acrotest.tex shipped out with the `acronym' % package \documentclass{article} +\usepackage[T1]{fontenc} +\usepackage[utf8]{inputenc} +\usepackage[english]{babel} +\usepackage{fixltx2e} \usepackage[colorlinks]{hyperref} \usepackage{acro} +\DeclareInstance{acro-extra}{paren}{default}{ + punct = true , + punct-symbol = +} \acsetup{sort,page-ref=comma,extra-style=paren,hyperref} -\DeclareAcronym{CDMA}{CDMA}{Code Division Multiple Access} -\DeclareAcronym{GSM}{GSM}{Global System for Mobile communication} -\DeclareAcronym{NA}{\ensuremath{N_{\mathrm A}}}{Number of Avogadro}{see \S\ref{Chem}} -\DeclareAcronym{NAD+}{NAD\textsuperscript{+}}{Nicotinamide Adenine Dinucleotide} -\DeclareAcronym{NUA}{NUA}{Not Used Acronym} -\DeclareAcronym{TDMA}{TDMA}{Time Division Multiple Access} -\DeclareAcronym{UA}{UA}{Used Acronym} -\DeclareAcronym{lox}{\ensuremath{LOX}}{Liquid Oxygen}% -\DeclareAcronym{lh2}{\ensuremath{LH_2}}{Liquid Hydrogen}% -\DeclareAcronym{IC}{IC}{Integrated Circuit}% -\DeclareAcronym*{BUT}{BUT}{Block Under Test,Blocks Under Test}% +\DeclareAcronym{CDMA}{ + short = CDMA , + long = Code Division Multiple Access , + long-plural = es +} +\DeclareAcronym{GSM}{ + short = GSM , + long = Global System for Mobile communication +} +\DeclareAcronym{NA}{ + short = {\ensuremath{N_{\mathrm{A}}}} , + long = Number of Avogadro , + extra = see \S\ref{Chem} , + pdfstring = NA +} +\DeclareAcronym{NAD+}{ + short = {NAD\textsuperscript{+}} , + short-plural = , + long = Nicotinamide Adenine Dinucleotide , + pdfstring = NAD+ +} +\DeclareAcronym{NUA}{ + short = NUA , + long = Not Used Acronym +} +\DeclareAcronym{TDMA}{ + short = TDMA , + long = Time Division Multiple Access , + long-plural = es +} +\DeclareAcronym{UA}{ + short = UA , + long = Used Acronym +} +\DeclareAcronym{lox}{ + short = {\emph{LOX}} , + long = Liquid Oxygen , + pdfstring = LOX +} +\DeclareAcronym{lh2}{ + short = {\emph{LH\textsubscript{2}}} , + long = Liquid Hydrogen , + pdfstring = LH2 +} +\DeclareAcronym{IC}{ + short = IC , + long = Integrated Circuit +} +\DeclareAcronym{BUT}{ + short = BUT , + long = Block Under Test , + long-plural-form = Blocks Under Test +} \begin{document} \section{Intro} diff --git a/Master/texmf-dist/tex/latex/acro/acro.sty b/Master/texmf-dist/tex/latex/acro/acro.sty index f867b88fe19..fb8b8c09105 100644 --- a/Master/texmf-dist/tex/latex/acro/acro.sty +++ b/Master/texmf-dist/tex/latex/acro/acro.sty @@ -23,7 +23,7 @@ % The Current Maintainer of this work is Clemens Niederberger. % -------------------------------------------------------------------------- % The acro package consists of the files -% - acro.sty, acro_en.tex, acro_en.pdf, README +% - acro.sty, acro0.def, acro1.def, acro_en.tex, acro_en.pdf, README % -------------------------------------------------------------------------- % If you have any ideas, questions, suggestions or bugs to report, please % feel free to contact me. @@ -31,11 +31,11 @@ \RequirePackage{expl3,xparse,l3keys2e,xtemplate} \ProvidesExplPackage {acro} - {2013/01/02} - {0.6a} + {2013/01/16} + {1.0} {Typeset Acronyms} -% error messages: +% warning and error messages: \msg_new:nnnn { acro } { undefined } { You've~requested~acronym~`#1'~but~it~seems~that~it~was~never~defined! } { @@ -43,12 +43,23 @@ apperantly~haven't~defined~it,~yet!~Maybe~you've~mispelled~it? } +\msg_new:nnnn { acro } { version } + { You've~selected~the~version~option~`#1'~which~doesn't~exist. } + { + You've~selected~the~version~option~`#1'~which~doesn't~exist.~ + I'm~using~option~`#2'~instead. + } + % temporary variables \tl_new:N \l__acro_tmpa_tl \tl_new:N \l__acro_tmpb_tl \tl_new:N \l__acro_tmpc_tl \prop_new:N \l__acro_tmpa_prop +\prop_new:N \l__acro_tmpb_prop \seq_new:N \l__acro_tmpa_seq +\seq_new:N \l__acro_tmpb_seq + +\tl_new:N \l__acro_ignore_tl % boolean variables: \bool_new:N \l__acro_mark_as_used_bool @@ -64,10 +75,16 @@ \bool_new:N \l__acro_xspace_bool \bool_new:N \l__acro_first_upper_bool \bool_new:N \l__acro_sort_bool +\bool_set_true:N \l__acro_sort_bool \bool_new:N \l__acro_capitalize_list_bool \bool_new:N \l__acro_citation_all_bool \bool_new:N \l__acro_citation_first_bool \bool_set_true:N \l__acro_citation_first_bool +\bool_new:N \l__acro_acc_supp_bool +\bool_new:N \l__acro_page_ranges_bool +\bool_set_true:N \l__acro_page_ranges_bool +\bool_new:N \l__acro_record_pages_bool +\bool_set_true:N \l__acro_record_pages_bool % tokenlist variables: \tl_new:N \l__acro_short_format_tl @@ -81,7 +98,13 @@ \tl_new:N \l__acro_page_instance_tl \tl_set:Nn \l__acro_page_instance_tl { none } \tl_new:N \l__acro_page_name_tl -\tl_set:Nn \l__acro_page_name_tl { p. } +\tl_set:Nn \l__acro_page_name_tl { p.\@\, } +\tl_new:N \l__acro_pages_name_tl +\tl_set:Nn \l__acro_pages_name_tl { pp.\@\, } +\tl_new:N \l__acro_next_page_tl +\tl_set:Nn \l__acro_next_page_tl { \,f.\@ } +\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_new:N \l__acro_list_type_tl @@ -104,6 +127,7 @@ % property list variables: \prop_new:N \l__acro_short_prop \prop_new:N \l__acro_alt_prop +\prop_new:N \l__acro_sort_prop \prop_new:N \l__acro_long_prop \prop_new:N \l__acro_class_prop \prop_new:N \l__acro_replace_plural_prop @@ -116,6 +140,7 @@ \prop_new:N \l__acro_citation_post_prop \prop_new:N \l__acro_pdfstring_prop \prop_new:N \l__acro_pdfstring_plural_prop +\prop_new:N \l__acro_acc_supp_prop % length variables: \dim_new:N \l__acro_table_width_dim @@ -129,9 +154,39 @@ \cs_new_eq:NN \acro_first_upper_case:n \__acro_first_upper_case:n +% -------------------------------------------------------------------------- +% versioning: +\tl_new:N \l__acro_active_version_tl +\tl_new:N \l__acro_version_zero_tl +\tl_set:Nn \l__acro_version_zero_tl { 0 } + +\clist_new:N \l__acro_versions_clist +\clist_put_right:Nn \l__acro_versions_clist { 0 } +\clist_put_right:Nn \l__acro_versions_clist { 1 } + +\bool_new:N \l__acro_version_selected_bool + +\cs_new:Npn \__acro_select_version:n #1 + { + \clist_if_in:NnTF \l__acro_versions_clist { #1 } + { + \file_input:n { acro#1.def } + \tl_set:Nn \l__acro_active_version_tl { #1 } + } + { + \msg_warning:nnxx { acro } { version } { #1 } { 1 } + \file_input:n { acro1.def } + \tl_set:Nn \l__acro_active_version_tl { 1 } + } + \bool_set_true:N \l__acro_version_selected_bool + } + + % options: \keys_define:nn { acro } { + version .code:n = \__acro_select_version:n { #1 } , + accsupp .bool_set:N = \l__acro_acc_supp_bool , macros .bool_set:N = \l__acro_create_macros_bool , xspace .bool_set:N = \l__acro_xspace_bool , strict .bool_set:N = \l__acro_strict_bool , @@ -147,6 +202,11 @@ extra-style .tl_set:N = \l__acro_extra_instance_tl , page-ref .tl_set:N = \l__acro_page_instance_tl , page-name .tl_set:N = \l__acro_page_name_tl , + pages-name .tl_set:N = \l__acro_pages_name_tl , + page-ranges .bool_set:N = \l__acro_page_ranges_bool , + record-pages .bool_set:N = \l__acro_record_pages_bool , + next-page .tl_set:N = \l__acro_next_page_tl , + next-pages .tl_set:N = \l__acro_next_pages_tl , list-style .tl_set:N = \l__acro_list_instance_tl , list-type .tl_set:N = \l__acro_list_type_tl , list-header .tl_set:N = \l__acro_list_title_tl , @@ -184,65 +244,14 @@ \cs_new_eq:NN \acro_xspace: \xspace } { \cs_new:Npn \acro_xspace: {} } + \bool_if:NF \l__acro_record_pages_bool + { \cs_set_eq:NN \__acro_record_page_number:n \use_none:n } } % setup command: \NewDocumentCommand \acsetup { m } { \keys_set:nn { acro } { #1 } \ignorespaces } -% -------------------------------------------------------------------------- -% adding an acronym, internal command: -% #1: use/replace plural (boolean) -% #2: id -% #3: short -% #4: short plural -% #5: alt -% #6: long -% #7: long plural -% #8: class -% #9: extra -\cs_new:Npn \acro_new:nnnnnnnnn #1#2#3#4#5#6#7#8#9 - { - \IfBooleanTF { #1 } - { \prop_put:Nnn \l__acro_replace_plural_prop { #2 } { \c_true_bool } } - { \prop_put:Nnn \l__acro_replace_plural_prop { #2 } { \c_false_bool } } - \prop_put:Nnn \l__acro_short_prop { #2 } { #3 } - \prop_put:Nnn \l__acro_pdfstring_prop { #2 } { #3 } - \IfNoValueTF { #4 } - { - \prop_put:Nnn \l__acro_short_plural_prop - { #2 } { \l__acro_default_plural_tl } - \prop_put:Nnx \l__acro_pdfstring_plural_prop - { #2 } { \exp_not:n { #3 } \exp_not:V \l__acro_default_plural_tl } - } - { - \prop_put:Nnn \l__acro_short_plural_prop { #2 } { #4 } - \prop_put:Nnx \l__acro_pdfstring_plural_prop { #2 } { \exp_not:n { #3 #4 } } - } - \IfNoValueTF { #5 } - { \prop_put:Nnn \l__acro_alt_prop { #2 } { #2 } } - { \prop_put:Nnn \l__acro_alt_prop { #2 } { #5 } } - \prop_put:Nnn \l__acro_long_prop { #2 } { #6 } - \IfNoValueTF { #7 } - { \prop_put:Nnn \l__acro_long_plural_prop { #2 } { \l__acro_default_plural_tl } } - { \prop_put:Nnn \l__acro_long_plural_prop { #2 } { #7 } } - \IfNoValueF { #8 } - { \prop_put:Nnn \l__acro_class_prop { #2 } { #8} } - \IfNoValueF { #9 } - { \prop_put:Nnn \l__acro_extra_prop { #2 } { #9 } } - \bool_new:c { g__acro_#2_used_bool } - \bool_new:c { g__acro_#2_label_bool } - \bool_if:NT \l__acro_create_macros_bool - { - \cs_if_exist:cTF { #2 } - { - \bool_if:NT \l__acro_strict_bool - { \cs_set:cpn { #2 } { \ac { #2 } \acro_xspace: } } - } - { \cs_new:cpn { #2 } { \ac { #2 } \acro_xspace: } } - } - } - % typeset the short form: \cs_new:Npn \__acro_write_short:n #1 { @@ -312,7 +321,7 @@ \ifHy@ocgcolorlinks \exp_after:wN \use_i:nn \else - \exp_after:wN \use_ii:nn + \exp_after:wN \exp_after:wN \exp_after:wN \use_ii:nn \fi \fi { \textcolor { \@linkcolor } { #1 } } @@ -368,7 +377,7 @@ } \bool_if:nT { \l__acro_first_use_brackets_bool && !\l__acro_first_reversed_bool } { \tl_head:N \l__acro_first_brackets_tl } - \__acro_write_short:n { #2 } + \__acro_acc_supp:nn { #1 } { \__acro_write_short:n { #2 } } \bool_if:nT { \l__acro_first_use_brackets_bool && !\l__acro_first_reversed_bool } { \tl_tail:N \l__acro_first_brackets_tl } \bool_if:nT { !\l__acro_first_only_short_bool && \l__acro_first_reversed_bool } @@ -392,7 +401,7 @@ \DeclareTemplateCode { acro-first } { footnote } { 3 } { } { \AssignTemplateKeys - \__acro_write_short:n { #2 } + \__acro_acc_supp:nn { #1 } { \__acro_write_short:n { #2 } } \footnote { \__acro_write_long:No \l__acro_long_format_tl { #3 } @@ -460,12 +469,234 @@ { punct = true, brackets = false } % -------------------------------------------------------------------------- -% outputting the page number: +% outputting the page numbers: \bool_new:N \l__acro_page_punct_bool +\bool_new:N \l__acro_page_brackets_bool \bool_new:N \l__acro_page_display_bool \tl_new:N \l__acro_page_punct_tl +\tl_new:N \l__acro_page_brackets_tl \dim_new:N \l__acro_page_space_dim +\cs_new:Npn \acro_create_page_records:n #1 + { + \seq_new:c { g__acro_#1_tmp_seq } + \seq_new:c { g__acro_#1_pages_seq } + } + +\cs_new:Npn \acro@hyper@page #1 + { + \tl_if_in:nnTF { #1 } { \acro@no@hyperpage } + { #1 } + { \acro_hyper_page:n { #1 } } + } + +\cs_new_protected:Npn \acro@no@hyperpage {} + +\cs_new:Npn \__acro_safe_pages_aux:n #1 + { \noexpand \acro@hyper@page {#1}| } + +\cs_new_eq:NN \acro_hyper_page:n \use:n + +\cs_new:Npn \acro_safe_pages:n #1 + { + \iow_now:Nx \@auxout + { + \exp_not:n { \global \@namedef } { acro@#1@pages } + { \seq_map_function:cN { g__acro_#1_pages_seq } \__acro_safe_pages_aux:n } + } + } + +\AtEndDocument + { + \prop_map_inline:Nn \l__acro_short_prop + { + \acro_finalize_page_numbers:n { #1 } + \acro_safe_pages:n { #1 } + } + } + +\tl_new:N \l__acro_tmp_page_tl +\tl_new:N \l__acro_last_page_tl + +%TODO: this should be translated into expl3 syntax +\cs_new:Npn \__acro_if_is_number:nTF #1 + { + \if!\ifnum9<1#1!\expandafter\expandafter\expandafter\@firstoftwo\fi + \else + \expandafter\@secondoftwo + \fi + } + +\cs_new:Npn \__acro_convert_to_arabic:n #1 + { + \__acro_if_is_number:nTF { #1 } + { #1 } + { \exp_args:Nf \int_from_roman:n { \tl_expandable_lowercase:n { #1 } } } + } +\cs_generate_variant:Nn \__acro_convert_to_arabic:n { V } + +\cs_new:Npn \__acro_record_page_number:n #1 + { + \seq_if_empty:cTF { g__acro_#1_pages_seq } + {% no pages recorded, yet + \seq_gput_right:cx { g__acro_#1_pages_seq } { \thepage } + \seq_gput_right:cx { g__acro_#1_tmp_seq } { \thepage } + } + { + \seq_get_right:cN { g__acro_#1_tmp_seq } \l__acro_tmp_page_tl + \seq_get_right:cN { g__acro_#1_pages_seq } \l__acro_last_page_tl + \tl_if_eq:NNTF \l__acro_tmp_page_tl \l__acro_last_page_tl + {% range may have started + \int_compare:nNnF + { \value{page} } + = + { \__acro_convert_to_arabic:V \l__acro_tmp_page_tl } + { + \int_compare:nNnTF + { \value{page} } + = + { \__acro_convert_to_arabic:V \l__acro_tmp_page_tl + 1 } + {% range continues + \seq_gput_right:cx { g__acro_#1_tmp_seq } { \thepage } + } + {% no range (any more) + \seq_gput_right:cx { g__acro_#1_pages_seq } { \acro@no@hyperpage,~ } + \seq_gclear:c { g__acro_#1_tmp_seq } + \seq_gput_right:cx { g__acro_#1_tmp_seq } { \thepage } + \seq_gput_right:cx { g__acro_#1_pages_seq } { \thepage } + } + } + } + {% we're in a range + \int_compare:nNnF + { \value{page} } + = + { \__acro_convert_to_arabic:V \l__acro_tmp_page_tl } + { + \int_compare:nNnTF + { \value{page} } + = + { \__acro_convert_to_arabic:V \l__acro_tmp_page_tl + 1 } + {% range continues + \seq_gput_right:cx { g__acro_#1_tmp_seq } { \thepage } + } + {% no range (any more) + \int_compare:nNnTF + { \__acro_convert_to_arabic:V \l__acro_tmp_page_tl } + = + { \__acro_convert_to_arabic:V \l__acro_last_page_tl +1 } + { + \bool_if:NTF \l__acro_page_ranges_bool + { + \seq_gput_right:cn { g__acro_#1_pages_seq } + { \acro@no@hyperpage,~ } + \seq_gput_right:cx { g__acro_#1_pages_seq } + { \l__acro_tmp_page_tl } + } + { + \seq_gput_right:cn { g__acro_#1_pages_seq } + { \acro@no@hyperpage\l__acro_next_page_tl } + } + } + { + \bool_if:NTF \l__acro_page_ranges_bool + { + \seq_gput_right:cn { g__acro_#1_pages_seq } + { \acro@no@hyperpage-- } + \seq_gput_right:cx { g__acro_#1_pages_seq } + { \l__acro_tmp_page_tl } + } + { + \seq_gput_right:cn { g__acro_#1_pages_seq } + { \acro@no@hyperpage\l__acro_next_pages_tl } + } + } + \seq_gclear:c { g__acro_#1_tmp_seq } + \seq_gput_right:cx { g__acro_#1_tmp_seq } { \thepage } + \seq_gput_right:cn { g__acro_#1_pages_seq } { \acro@no@hyperpage,~ } + \seq_gput_right:cx { g__acro_#1_pages_seq } { \thepage } + } + } + } + } + } + +\cs_new:Npn \acro_finalize_page_numbers:n #1 + { + \seq_get_right:cN { g__acro_#1_tmp_seq } \l__acro_tmp_page_tl + \seq_get_right:cN { g__acro_#1_pages_seq } \l__acro_last_page_tl + \tl_if_eq:NNF \l__acro_tmp_page_tl \l__acro_last_page_tl + { + \int_compare:nNnTF + { \__acro_convert_to_arabic:V \l__acro_tmp_page_tl } + = + { \__acro_convert_to_arabic:V \l__acro_last_page_tl +1 } + { + \bool_if:NTF \l__acro_page_ranges_bool + { + \seq_gput_right:cn { g__acro_#1_pages_seq } + { \acro@no@hyperpage,~ } + \seq_gput_right:cx { g__acro_#1_pages_seq } + { \l__acro_tmp_page_tl } + } + { + \seq_gput_right:cn { g__acro_#1_pages_seq } + { \acro@no@hyperpage\l__acro_next_page_tl } + } + } + { + \bool_if:NTF \l__acro_page_ranges_bool + { + \seq_gput_right:cn { g__acro_#1_pages_seq } + { \acro@no@hyperpage-- } + \seq_gput_right:cx { g__acro_#1_pages_seq } + { \l__acro_tmp_page_tl } + } + { + \seq_gput_right:cn { g__acro_#1_pages_seq } + { \acro@no@hyperpage\l__acro_next_pages_tl } + } + } + } + } + +\cs_new:Npn \acro_print_page_numbers:n #1 + { + \cs_if_exist:cTF { acro@#1@pages } + { + \tl_set_eq:Nc \l__acro_tmpa_tl { acro@#1@pages } + \__acro_print_page_numbers:n { #1 } + } + { ?? } + } + +\cs_new:Npn \__acro_print_page_numbers:n #1 + { + \seq_set_split:NnV \l__acro_tmpb_seq { | } \l__acro_tmpa_tl + \seq_pop_right:NN \l__acro_tmpb_seq \l__acro_ignore_tl + \int_compare:nNnTF { \seq_count:N \l__acro_tmpb_seq } = { 1 } + { \l__acro_page_name_tl } { \l__acro_pages_name_tl } + \acro_no_break: + \skip_horizontal:N \l__acro_page_space_dim + \acro_no_break: + \seq_map_inline:Nn \l__acro_tmpb_seq { ##1 } + } + +\AtBeginDocument + { + \tl_if_eq:NNT \l__acro_active_version_tl \l__acro_version_zero_tl + { + \cs_set:Npn \__acro_print_page_numbers:n #1 + { + \acro_no_break: + \skip_horizontal:N \l__acro_page_space_dim + \acro_no_break: + \tl_use:N \l__acro_page_name_tl + \pageref{ac:#1} + } + } + } + \cs_new:Npn \acro_no_break: { \tex_penalty:D \c_ten_thousand } \DeclareObjectType { acro-page-number } { 1 } @@ -477,8 +708,7 @@ punct-symbol : tokenlist = {,} , brackets : boolean = false , brackets-type : tokenlist = () , - space : length = .3ex , - name : tokenlist , + space : length = .3ex } \DeclareTemplateCode { acro-page-number } { default } { 1 } @@ -488,8 +718,7 @@ punct-symbol = \l__acro_page_punct_tl , brackets = \l__acro_page_brackets_bool , brackets-type = \l__acro_page_brackets_tl , - space = \l__acro_page_space_dim , - name = \l__acro_page_name_tl , + space = \l__acro_page_space_dim } { \AssignTemplateKeys @@ -500,11 +729,7 @@ \tl_use:N \c_space_tl \bool_if:NT \l__acro_page_brackets_bool { \tl_head:N \l__acro_page_brackets_tl } - \tl_use:N \l__acro_page_name_tl - \acro_no_break: - \skip_horizontal:N \l__acro_page_space_dim - \acro_no_break: - \pageref { ac:#1 } + \acro_print_page_numbers:n { #1 } \bool_if:NT \l__acro_page_brackets_bool { \tl_tail:N \l__acro_page_brackets_tl } } @@ -568,7 +793,7 @@ \cs_new:Npn \acro_is_excluded:nnF #1#2#3 { \bool_set_false:N \l__acro_is_excluded_bool - \IfNoValueTF { #2 } + \tl_if_empty:nTF { #2 } { #3 } { \clist_map_inline:nn { #2 } @@ -649,7 +874,14 @@ \AssignTemplateKeys \__acro_activate_hyperref_support: \cs_set:Npn \acro_print_list_short:nn ##1##2 - { \item [ \acro_hyper_target:nn { ##1 } { \__acro_write_short:n { ##2 } } ] } + { + \item + [ + \acro_hyper_target:nn + { ##1 } + { \__acro_acc_supp:nn { ##1 } { \__acro_write_short:n { ##2 } } } + ] + } \cs_set:Npn \acro_print_list_long:n ##1 { \__acro_write_long:Nf \l__acro_list_long_format_tl @@ -693,7 +925,12 @@ \AssignTemplateKeys \__acro_activate_hyperref_support: \cs_set:Npn \acro_print_list_short:nn ##1##2 - { \acro_hyper_target:nn { ##1 } { \__acro_write_short:n { ##2 } } & } + { + \acro_hyper_target:nn + { ##1 } + { \__acro_acc_supp:nn { ##1 } { \__acro_write_short:n { ##2 } } } + & + } \cs_set:Npn \acro_print_list_long:n ##1 { \__acro_write_long:Nf \l__acro_list_long_format_tl @@ -735,7 +972,12 @@ \AssignTemplateKeys \__acro_activate_hyperref_support: \cs_set:Npn \acro_print_list_short:nn ##1##2 - { \acro_hyper_target:nn { ##1 } { \__acro_write_short:n { ##2 } } & } + { + \acro_hyper_target:nn + { ##1 } + { \__acro_acc_supp:nn { ##1 } { \__acro_write_short:n { ##2 } } } + & + } \cs_set:Npn \acro_print_list_long:n ##1 { \__acro_write_long:Nf \l__acro_list_long_format_tl @@ -779,7 +1021,12 @@ \AssignTemplateKeys \__acro_activate_hyperref_support: \cs_set:Npn \acro_print_list_short:nn ##1##2 - { \acro_hyper_target:nn { ##1 } { \__acro_write_short:n { ##2 } } & } + { + \acro_hyper_target:nn + { ##1 } + { \__acro_acc_supp:nn { ##1 } { \__acro_write_short:n { ##2 } } } + & + } \cs_set:Npn \acro_print_list_extra:n ##1 { \bool_if:NT \l__acro_capitalize_list_bool @@ -835,7 +1082,9 @@ \acro_is_used:nTF { #1 } { % this is not the first time - \__acro_write_short:V \l__acro_short_tl + \__acro_acc_supp:nn + { #1 } + { \__acro_write_short:V \l__acro_short_tl } \__acro_cite_if:Nn \l__acro_citation_all_bool { #1 } } { @@ -914,7 +1163,11 @@ \iow_now:Nx \@auxout { \string \acro@used@once { #1 } } \bool_if:NT \l__acro_mark_as_used_bool { - \bool_if:cF { g__acro_#1_label_bool } + \bool_if:nT + { + !\bool_if_p:c { g__acro_#1_label_bool } && + \tl_if_eq_p:NN \l__acro_active_version_tl \l__acro_version_zero_tl + } { \bool_gset_true:c { g__acro_#1_label_bool } \label{ac:#1} @@ -952,7 +1205,9 @@ \acro_is_used:n { #1 } \__acro_is_single:nT { #1 } { \cs_set_eq:NN \acro_hyper_link:nn \use_ii:nn } - \__acro_write_short:V \l__acro_short_tl + \__acro_acc_supp:nn + { #1 } + { \__acro_write_short:V \l__acro_short_tl } \__acro_cite_if:Nn \l__acro_citation_all_bool { #1 } } @@ -964,7 +1219,9 @@ \acro_is_used:n { #1 } \__acro_is_single:nT { #1 } { \cs_set_eq:NN \acro_hyper_link:nn \use_ii:nn } - \__acro_write_short:V \l__acro_alt_tl + \__acro_acc_supp:nn + { #1 } + { \__acro_write_short:V \l__acro_alt_tl } \__acro_cite_if:Nn \l__acro_citation_all_bool { #1 } } @@ -994,20 +1251,6 @@ { \l__acro_long_tl } } -% set custom format: -\cs_new:Npn \acro_format:nn #1#2 - { \prop_put:Nnn \l__acro_format_prop { #1 } { #2 } } - -% add citation: -\cs_new:Npn \acro_citation:nnnn #1#2#3#4 - { - \prop_put:Nnn \l__acro_citation_prop { #1 } { #4 } - \IfNoValueF { #2 } - { \prop_put:Nnn \l__acro_citation_pre_prop { #1 } { #2 } } - \IfNoValueF { #3 } - { \prop_put:Nnn \l__acro_citation_post_prop { #1 } { #3 } } - } - % #1 pre % #2 post % #3 key @@ -1041,6 +1284,34 @@ } } +% accessability support +\tl_new:N \l__acro_acc_supp_tl +\cs_new_eq:NN \__acro_acc_supp:nn \use_ii:nn + +\cs_new:Npn \__acro_acc_supp_aux:nn #1#2 + { + \BeginAccSupp { ActualText = #1 } + #2 + \EndAccSupp { } + } +\cs_generate_variant:Nn \__acro_acc_supp_aux:nn { V } + +\AtBeginDocument + { + \bool_if:NT \l__acro_acc_supp_bool + { + \RequirePackage { accsupp } + \cs_set:Npn \__acro_acc_supp:nn #1#2 + { + \prop_get:NnNF \l__acro_acc_supp_prop { #1 } \l__acro_acc_supp_tl + { \prop_get:NnN \l__acro_short_prop { #1 } \l__acro_acc_supp_tl } + \bool_if:NT \l__acro_use_plural_bool + { \tl_put_right:NV \l__acro_acc_supp_tl \l__acro_short_plural_tl } + \__acro_acc_supp_aux:Vn \l__acro_acc_supp_tl { #2 } + } + } + } + % -------------------------------------------------------------------------- % experimental sorting feature: \AtBeginDocument @@ -1050,9 +1321,14 @@ \RequirePackage { l3sort } \cs_new:Npn \acro_sort_prop:N #1 { - \seq_clear:N \l__acro_tmpa_seq - \prop_map_inline:Nn #1 - { \seq_put_right:Nn \l__acro_tmpa_seq { ##1 } } + \seq_clear:N \l__acro_tmpa_seq + \prop_clear:N \l__acro_tmpa_prop + \prop_clear:N \l__acro_tmpb_prop + \prop_map_inline:Nn \l__acro_sort_prop + { + \seq_put_right:Nn \l__acro_tmpa_seq { ##2 } + \prop_put:Nnn \l__acro_tmpa_prop { ##2 } { ##1 } + } \seq_sort:Nn \l__acro_tmpa_seq { \tl_to_lowercase:n { @@ -1061,80 +1337,47 @@ { \sort_reversed: } } } - \prop_clear:N \l__acro_tmpa_prop \seq_map_inline:Nn \l__acro_tmpa_seq { - \prop_get:NnN #1 { ##1 } \l__acro_tmpa_tl - \prop_put:NnV \l__acro_tmpa_prop { ##1 } \l__acro_tmpa_tl + % get ID: + \prop_get:NnN \l__acro_tmpa_prop { ##1 } \l__acro_tmpa_tl + % get prop entry of ID in #1: + \prop_get:NVNT #1 \l__acro_tmpa_tl \l__acro_tmpb_tl + { + \prop_put:NVV \l__acro_tmpb_prop + \l__acro_tmpa_tl + \l__acro_tmpb_tl + } } - \prop_set_eq:NN #1 \l__acro_tmpa_prop + \prop_set_eq:NN #1 \l__acro_tmpb_prop } } } % -------------------------------------------------------------------------- -% print the whole list: -\cs_new:Npn \acro_print_acronyms:nn #1#2 - { - \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 } - \cs_if_exist:NTF \acro@printed@list - { - \UseInstance { acro-list } { \l__acro_list_instance_tl } - { \l__acro_list_type_tl } { #1 } { #2 } - } - { \@latex@warning@no@line {Rerun~to~get~acronym~list~right} } - } - +% regarding list printing: \cs_new:Npn \acro@print@list { \cs_if_exist:NF \acro@printed@list { \cs_new:Npn \acro@printed@list {} } } -% -------------------------------------------------------------------------- -% USER COMMANDS -% adding an acronym, user command: -% #1: use/replace plural (boolean) -% #2: id -% #3: short -% #4: short plural -% #5: alt -% #6: long -% #7: long plural -% #8: class -% #9: extra -\NewDocumentCommand \DeclareAcronym - { sm>{\SplitArgument{1}{,}}mo>{\SplitArgument{1}{,}}+mgo } - { \acro_new:nnnnnnnnn { #1 } { #2 } #3 { #4 } #5 { #7 } { #6 } } -\@onlypreamble \DeclareAcronym - -\NewDocumentCommand \DeclareAcronymFormat { mm } - { \acro_format:nn { #1 } { #2 } } -\@onlypreamble \DeclareAcronymFormat - -\NewDocumentCommand \DeclareAcronymCitation { moom } - { \acro_citation:nnnn { #1 } { #2 } { #3 } { #4 } } -\@onlypreamble \DeclareAcronymCitation - -\NewDocumentCommand \DeclareAcronymPDFString - { m >{ \SplitArgument { 1 } { , } } m } - { \acro_pdfstring:nnn { #1 } #2 } -\@onlypreamble \DeclareAcronymPDFstring - -\cs_new:Npn \acro_use_if:n #1 + +\cs_new:Npn \acro_use_if:nn #1#2 { \IfBooleanTF { #1 } { \bool_set_false:N \l__acro_mark_as_used_bool } - { \bool_set_true:N \l__acro_mark_as_used_bool } + { + \__acro_record_page_number:n { #2 } + \bool_set_true:N \l__acro_mark_as_used_bool + } } +% -------------------------------------------------------------------------- +% the user commands: % automatic: \NewDocumentCommand \ac { sm } { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \acro_use:n { #2 } \group_end: } @@ -1143,7 +1386,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \bool_set_true:N \l__acro_first_upper_bool \acro_use:n { #2 } \group_end: @@ -1153,7 +1396,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \bool_set_true:N \l__acro_use_plural_bool \acro_use:n { #2 } \group_end: @@ -1163,7 +1406,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \bool_set_true:N \l__acro_use_plural_bool \bool_set_true:N \l__acro_first_upper_bool \acro_use:n { #2 } @@ -1175,7 +1418,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \acro_short:n { #2 } \group_end: } @@ -1184,7 +1427,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \bool_set_true:N \l__acro_use_plural_bool \acro_short:n { #2 } \group_end: @@ -1195,7 +1438,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \acro_alt:n { #2 } \group_end: } @@ -1204,7 +1447,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \bool_set_true:N \l__acro_use_plural_bool \acro_alt:n { #2 } \group_end: @@ -1215,7 +1458,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \acro_long:n { #2 } \group_end: } @@ -1224,7 +1467,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \bool_set_true:N \l__acro_first_upper_bool \acro_long:n { #2 } \group_end: @@ -1234,7 +1477,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \bool_set_true:N \l__acro_use_plural_bool \acro_long:n { #2 } \group_end: @@ -1244,7 +1487,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \bool_set_true:N \l__acro_use_plural_bool \bool_set_true:N \l__acro_first_upper_bool \acro_long:n { #2 } @@ -1256,7 +1499,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \acro_first:n { #2 } \group_end: } @@ -1265,7 +1508,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \bool_set_true:N \l__acro_first_upper_bool \acro_first:n { #2 } \group_end: @@ -1275,7 +1518,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \bool_set_true:N \l__acro_use_plural_bool \acro_first:n { #2 } \group_end: @@ -1285,7 +1528,7 @@ { \group_begin: \acro_defined:n { #2 } - \acro_use_if:n { #1 } + \acro_use_if:nn { #1 } { #2 } \bool_set_true:N \l__acro_use_plural_bool \bool_set_true:N \l__acro_first_upper_bool \acro_first:n { #2 } @@ -1321,9 +1564,7 @@ \NewDocumentCommand \acuse { > { \SplitList { , } } m } { \ProcessList { #1 } { \acro_mark_as_used:n } } -% typeset the list: -\NewDocumentCommand \printacronyms { G{}o } - { \acro_print_acronyms:nn { #1 } { #2 } } + \ProcessKeysOptions { acro } @@ -1352,20 +1593,6 @@ { \prop_get:Nn \l__acro_pdfstring_plural_prop { #1 } } } -\cs_new:Npn \acro_pdfstring:nnn #1#2#3 - { - \prop_put:Nnx \l__acro_pdfstring_prop { #1 } { #2 } - \IfNoValueTF { #3 } - { - \prop_put:Nnx \l__acro_pdfstring_plural_prop - { #1 } { #2 \l__acro_default_plural_tl } - } - { - \prop_put:Nnx \l__acro_pdfstring_plural_prop - { #1 } { #2 #3 } - } - } - \AtBeginDocument { \@ifpackageloaded { hyperref } @@ -1390,12 +1617,15 @@ \cs_set_eq:NN \Acfp \acpdfstringplural \cs_set_eq:NN \acap \acpdfstringplural } + \cs_set_eq:NN \acro_hyper_page:n \hyperpage } {} } % -------------------------------------------------------------------------- % language support \RequirePackage { translations } +% Listenname +\DeclareTranslationFallback { acronym-list-name } { Acronyms } \DeclareTranslation { English } { acronym-list-name } { Acronyms } \DeclareTranslation { American } { acronym-list-name } { Acronyms } \DeclareTranslation { British } { acronym-list-name } { Acronyms } @@ -1406,6 +1636,31 @@ \DeclareTranslation { Catalan } { acronym-list-name } { Sigles } \DeclareTranslation { Turkish } { acronym-list-name } { K\i saltmalar } \tl_set:Nn \l__acro_list_name_tl { \GetTranslation { acronym-list-name } } +% Seitenname +\DeclareTranslationFallback { acronym-page-name } { p. } +\DeclareTranslation { English } { acronym-page-name } { p. } +\DeclareTranslation { German } { acronym-page-name } { S. } +\tl_set:Nn \l__acro_page_name_tl { \GetTranslation { acronym-page-name }\@\, } +% Seitenname - Plural +\DeclareTranslationFallback { acronym-pages-name } { pp. } +\DeclareTranslation { English } { acronym-pages-name } { pp. } +\DeclareTranslation { German } { acronym-pages-name } { S. } +\tl_set:Nn \l__acro_pages_name_tl { \GetTranslation { acronym-pages-name }\@\, } +% einzelne folgende Seite +\DeclareTranslationFallback { acronym-next-page } { f. } +\DeclareTranslation { English } { acronym-next-page } { f. } +\DeclareTranslation { German } { acronym-next-page } { f. } +\tl_set:Nn \l__acro_next_page_tl { \,\GetTranslation {acronym-next-page }\@ } +% mehrere folgende Seiten +\DeclareTranslationFallback { acronym-next-pages } { ff. } +\DeclareTranslation { English } { acronym-next-pages } { ff. } +\DeclareTranslation { German } { acronym-next-pages } { ff. } +\tl_set:Nn \l__acro_next_pages_tl { \,\GetTranslation {acronym-next-pages }\@ } + +% -------------------------------------------------------------------------- +% load default version +\bool_if:NF \l__acro_version_selected_bool + { \__acro_select_version:n { 1 } } \tex_endinput:D % -------------------------------------------------------------------------- @@ -1443,30 +1698,24 @@ short entry) resolved - option `xspace' added 2013/01/02 v0.6a - \acuseall - +2013/01/16 v1.0 - new syntax of \DeclareAcronym + - new option `version' + - new `accsupp' acronym property + - new `sort' acronym property + - new syntax of \printacronyms + - new default: `sort=true' + - new options `page-ranges', `next-page', `next-pages', + `pages-name', `record-pages' + - no automatic label placement for page number referencing + any more + % -------------------------------------------------------------------------- % TODO: - Option `totoc'!? -- accsupp Support? - revise list styles to allow _full_ customization by creating own instances! this probably needs a handfull of macros that give access to the entries without worrying about internals - record and list _all_ pagenumbers where an acronym occurs - compilation halts instead of throwing an error if an undefined acronym is used -- possibility to add sort key - add \ACF, \ACFP, \ACL and \ACLP that will print all words of the long form - capitalized - -= long term = -- new syntax: - \DeclareAcronym{<ID>} - { - short = ?? , - long = ?? , - sort = ?? , - short-plural = ?? , - long-plural* = ?? ,% * = replacement instead of ending - PDF-text = ?? , - cite = ?? , - ... - }
\ No newline at end of file + capitalized
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/acro/acro0.def b/Master/texmf-dist/tex/latex/acro/acro0.def new file mode 100644 index 00000000000..673a6d2a164 --- /dev/null +++ b/Master/texmf-dist/tex/latex/acro/acro0.def @@ -0,0 +1,168 @@ +% -------------------------------------------------------------------------- +% the ACRO package +% +% Typeset Acronyms +% +% -------------------------------------------------------------------------- +% Clemens Niederberger +% Web: https://bitbucket.org/cgnieder/acro/ +% E-Mail: contact@mychemistry.eu +% -------------------------------------------------------------------------- +% Copyright 2011-2013 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 acro package consists of the files +% - acro.sty, acro0.def, acro1.def, acro_en.tex, acro_en.pdf, README +% -------------------------------------------------------------------------- +% If you have any ideas, questions, suggestions or bugs to report, please +% feel free to contact me. +% -------------------------------------------------------------------------- +\ProvidesFile{acro0.def} + +% -------------------------------------------------------------------------- +% adding an acronym, internal command: +% #1: use/replace plural (boolean) +% #2: id +% #3: short +% #4: short plural +% #5: alt +% #6: long +% #7: long plural +% #8: class +% #9: extra +\cs_new:Npn \acro_new:nnnnnnnnn #1#2#3#4#5#6#7#8#9 + { + \IfBooleanTF { #1 } + { \prop_put:Nnn \l__acro_replace_plural_prop { #2 } { \c_true_bool } } + { \prop_put:Nnn \l__acro_replace_plural_prop { #2 } { \c_false_bool } } + \prop_put:Nnn \l__acro_short_prop { #2 } { #3 } + \prop_put:Nnn \l__acro_sort_prop { #2 } { #2 } + \prop_put:Nnn \l__acro_pdfstring_prop { #2 } { #3 } + \acro_create_page_records:n { #2 } + \IfNoValueTF { #4 } + { + \prop_put:Nnn \l__acro_short_plural_prop + { #2 } { \l__acro_default_plural_tl } + \prop_put:Nnx \l__acro_pdfstring_plural_prop + { #2 } { \exp_not:n { #3 } \exp_not:V \l__acro_default_plural_tl } + } + { + \prop_put:Nnn \l__acro_short_plural_prop { #2 } { #4 } + \prop_put:Nnx \l__acro_pdfstring_plural_prop { #2 } { \exp_not:n { #3 #4 } } + } + \IfNoValueTF { #5 } + { \prop_put:Nnn \l__acro_alt_prop { #2 } { #2 } } + { \prop_put:Nnn \l__acro_alt_prop { #2 } { #5 } } + \prop_put:Nnn \l__acro_long_prop { #2 } { #6 } + \IfNoValueTF { #7 } + { \prop_put:Nnn \l__acro_long_plural_prop { #2 } { \l__acro_default_plural_tl } } + { \prop_put:Nnn \l__acro_long_plural_prop { #2 } { #7 } } + \IfNoValueF { #8 } + { \prop_put:Nnn \l__acro_class_prop { #2 } { #8 } } + \IfNoValueF { #9 } + { \prop_put:Nnn \l__acro_extra_prop { #2 } { #9 } } + \bool_new:c { g__acro_#2_used_bool } + \bool_new:c { g__acro_#2_label_bool } + \bool_if:NT \l__acro_create_macros_bool + { + \cs_if_exist:cTF { #2 } + { + \bool_if:NT \l__acro_strict_bool + { \cs_set:cpn { #2 } { \ac { #2 } \acro_xspace: } } + } + { \cs_new:cpn { #2 } { \ac { #2 } \acro_xspace: } } + } + } + +% set custom format: +\cs_new:Npn \acro_format:nn #1#2 + { \prop_put:Nnn \l__acro_format_prop { #1 } { #2 } } + +% add citation: +\cs_new:Npn \acro_citation:nnnn #1#2#3#4 + { + \prop_put:Nnn \l__acro_citation_prop { #1 } { #4 } + \IfNoValueF { #2 } + { \prop_put:Nnn \l__acro_citation_pre_prop { #1 } { #2 } } + \IfNoValueF { #3 } + { \prop_put:Nnn \l__acro_citation_post_prop { #1 } { #3 } } + } + +% add pdfstring: +\cs_new:Npn \acro_pdfstring:nnn #1#2#3 + { + \prop_put:Nnx \l__acro_pdfstring_prop { #1 } { #2 } + \IfNoValueTF { #3 } + { + \prop_put:Nnx \l__acro_pdfstring_plural_prop + { #1 } { #2 \l__acro_default_plural_tl } + } + { + \prop_put:Nnx \l__acro_pdfstring_plural_prop + { #1 } { #2 #3 } + } + } + +% -------------------------------------------------------------------------- +% USER COMMANDS +% adding an acronym, user command: +% #1: use/replace plural (boolean) +% #2: id +% #3: short +% #4: short plural +% #5: alt +% #6: long +% #7: long plural +% #8: class +% #9: extra +\NewDocumentCommand \DeclareAcronym + { sm>{\SplitArgument{1}{,}}mo>{\SplitArgument{1}{,}}+mgo } + { \acro_new:nnnnnnnnn { #1 } { #2 } #3 { #4 } #5 { #7 } { #6 } } +\@onlypreamble \DeclareAcronym + +\NewDocumentCommand \DeclareAcronymFormat { mm } + { \acro_format:nn { #1 } { #2 } } +\@onlypreamble \DeclareAcronymFormat + +\NewDocumentCommand \DeclareAcronymCitation { moom } + { \acro_citation:nnnn { #1 } { #2 } { #3 } { #4 } } +\@onlypreamble \DeclareAcronymCitation + +\NewDocumentCommand \DeclareAcronymPDFString + { m >{ \SplitArgument { 1 } { , } } m } + { \acro_pdfstring:nnn { #1 } #2 } +\@onlypreamble \DeclareAcronymPDFstring + +% -------------------------------------------------------------------------- +% print the list: +\cs_new:Npn \acro_print_acronyms:nn #1#2 + { + \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 } + \cs_if_exist:NTF \acro@printed@list + { + \UseInstance { acro-list } { \l__acro_list_instance_tl } + { \l__acro_list_type_tl } { #1 } { #2 } + } + { \@latex@warning@no@line {Rerun~to~get~acronym~list~right} } + } + +% user command: +\NewDocumentCommand \printacronyms { G{}O{} } + { \acro_print_acronyms:nn { #1 } { #2 } } + +\tex_endinput:D
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/acro/acro1.def b/Master/texmf-dist/tex/latex/acro/acro1.def new file mode 100644 index 00000000000..21d4e83fa92 --- /dev/null +++ b/Master/texmf-dist/tex/latex/acro/acro1.def @@ -0,0 +1,337 @@ +% -------------------------------------------------------------------------- +% the ACRO package +% +% Typeset Acronyms +% +% -------------------------------------------------------------------------- +% Clemens Niederberger +% Web: https://bitbucket.org/cgnieder/acro/ +% E-Mail: contact@mychemistry.eu +% -------------------------------------------------------------------------- +% Copyright 2011-2013 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 acro package consists of the files +% - acro.sty, acro0.def, acro1.def, acro_en.tex, acro_en.pdf, README +% -------------------------------------------------------------------------- +% If you have any ideas, questions, suggestions or bugs to report, please +% feel free to contact me. +% -------------------------------------------------------------------------- +\ProvidesFile{acro1.def} + +% -------------------------------------------------------------------------- +% additional variables: +\tl_new:N \l__acro_current_key_tl + +% -------------------------------------------------------------------------- +% key and order checking +\msg_new:nnnn { acro } { no-id } + { Something~has~gone~wrong,~you've~probably~forgotten~to~set~the~acronym~ID. } + { Something~has~gone~wrong,~you've~probably~forgotten~to~set~the~acronym~ID. } + +\msg_new:nnnn { acro } { before-short } + { The~key~`#2'~needs~to~be~set~after~`short'. } + { + You've~set~The~key~`#2'~before~the~`short'~key~for~acronym~`#1'~but~ + needs~to~be~set~after~it. + } + +\msg_new:nnnn { acro } { missing } + { The~`#2'~key~for~acronym~`#1'~is~missing. } + { The~`#2'~key~for~acronym~`#1'~is~missing. } + +% TODO: checking: +% - `sort' zuerst, darf nicht fehlen +% - `long' darf nicht fehlen +\cs_new:Npn \__acro_key_check:nn #1#2 + { + \tl_if_blank:VT \l__acro_current_key_tl + { \msg_error:nn { acro } { no-id } } + \bool_if:cF { l__acro_short_#1_set_bool } + { \msg_error:nnxx { acro } { before-short } { #1 } { #2 } } + } + +\cs_new:Npn \__acro_first_key_check:n #1 + { + \cs_if_exist:cTF { l__acro_short_#1_set_bool } + { + \bool_if:cTF { l__acro_short_#1_set_bool } + {} + { \bool_set_true:c { l__acro_short_#1_set_bool } } + } + {% error: key already used + } + } + +% -------------------------------------------------------------------------- +% the internal selection functions: +% short: +\cs_new:Npn \__acro_declare_short:nn #1#2 + { + \bool_new:c { l__acro_short_#1_set_bool } + \__acro_first_key_check:n { #1 } + \prop_put:Nnn \l__acro_short_prop { #1 } { #2 } + \prop_put:Nnn \l__acro_sort_prop { #1 } { #1 } + \prop_put:Nnn \l__acro_alt_prop { #1 } { #2 } + \prop_put:Nnx \l__acro_pdfstring_prop { #1 } { \exp_not:n { #2 } } + \prop_put:Nnn \l__acro_short_plural_prop + { #1 } { \l__acro_default_plural_tl } + \prop_put:Nnx \l__acro_pdfstring_plural_prop + { #1 } { \exp_not:n { #2 } \exp_not:V \l__acro_default_plural_tl } + } +\cs_generate_variant:Nn \__acro_declare_short:nn { V } + +\cs_new:Npn \__acro_declare_short_plural:nn #1#2 + { + \__acro_key_check:nn { #1 } { short-plural } + \prop_put:Nnn \l__acro_short_plural_prop { #1 } { #2 } + } +\cs_generate_variant:Nn \__acro_declare_short_plural:nn { V } + +% long: +\cs_new:Npn \__acro_declare_long:nn #1#2 + { + \__acro_key_check:nn { #1 } { long } + \bool_new:c { l__acro_long_#1_set_bool } + \prop_put:Nnn \l__acro_replace_plural_prop { #1 } { \c_false_bool } + \prop_put:Nnn \l__acro_long_prop { #1 } { #2 } + \prop_put:Nnn \l__acro_long_plural_prop + { #1 } { \l__acro_default_plural_tl } + \bool_set_true:c { l__acro_long_#1_set_bool } + } +\cs_generate_variant:Nn \__acro_declare_long:nn { V } + +% long plural: +\cs_new:Npn \__acro_declare_long_plural:nn #1#2 + { + \__acro_key_check:nn { #1 } { long-plural } + \prop_put:Nnn \l__acro_replace_plural_prop { #1 } { \c_false_bool } + \prop_put:Nnn \l__acro_long_plural_prop { #1 } { #2 } + } +\cs_generate_variant:Nn \__acro_declare_long_plural:nn { V } + +% long plural form: +\cs_new:Npn \__acro_declare_long_plural_form:nn #1#2 + { + \__acro_key_check:nn { #1 } { long-plural-form } + \prop_put:Nnn \l__acro_replace_plural_prop { #1 } { \c_true_bool } + \prop_put:Nnn \l__acro_long_plural_prop { #1 } { #2 } + } +\cs_generate_variant:Nn \__acro_declare_long_plural_form:nn { V } + +% sort: +\cs_new:Npn \__acro_declare_sort:nn #1#2 + { + \__acro_key_check:nn { #1 } { sort } + \prop_put:Nnn \l__acro_sort_prop { #1 } { #2 } + } +\cs_generate_variant:Nn \__acro_declare_sort:nn { V } + +% alternative: +\cs_new:Npn \__acro_declare_alt:nn #1#2 + { + \__acro_key_check:nn { #1 } { alt } + \prop_put:Nnn \l__acro_alt_prop { #1 } { #2 } + } +\cs_generate_variant:Nn \__acro_declare_alt:nn { V } + +% format: +\cs_new:Npn \__acro_declare_format:nn #1#2 + { + \__acro_key_check:nn { #1 } { format } + \prop_put:Nnn \l__acro_format_prop { #1 } { #2 } + } +\cs_generate_variant:Nn \__acro_declare_format:nn { V } + +% pdfstring: +\cs_new:Npn \__acro_declare_pdfstring:nw #1#2/#3/#4 \acro_stop: + { + \__acro_key_check:nn { #1 } { pdfstring } + \prop_put:Nnx \l__acro_pdfstring_prop { #1 } { #2 } + \tl_if_empty:nTF { #3 } + { + \prop_put:Nnx \l__acro_pdfstring_plural_prop + { #1 } { \exp_not:n { #2 } \exp_not:V \l__acro_default_plural_tl } + } + { + \prop_put:Nnx \l__acro_pdfstring_plural_prop + { #1 } { \exp_not:n { #2#3 } } + } + } + +% class: +\cs_new:Npn \__acro_declare_class:nn #1#2 + { + \__acro_key_check:nn { #1 } { class } + \prop_put:Nnn \l__acro_class_prop { #1 } { #2 } + } +\cs_generate_variant:Nn \__acro_declare_class:nn { V } + +% extra information: +\cs_new:Npn \__acro_declare_extra:nn #1#2 + { + \__acro_key_check:nn { #1 } { extra } + \prop_put:Nnn \l__acro_extra_prop { #1 } { #2 } + } +\cs_generate_variant:Nn \__acro_declare_extra:nn { V } + +% acc supp: +\cs_new:Npn \__acro_declare_acc_supp:nn #1#2 + { + \__acro_key_check:nn { #1 } { accsupp } + \prop_put:Nnn \l__acro_acc_supp_prop { #1 } { #2 } + } +\cs_generate_variant:Nn \__acro_declare_acc_supp:nn { V } + +% citation: +\cs_new:Npn \__acro_declare_citation:nw #1#2[#3]#4[#5]#6#7 \acro_stop: + { + % no options: #1: ID, #2: key, #3 is blank + % 1 option: #1: ID, #4: key, #3: option, #5 is blank + % 2 options: #1: ID: #6: key, #3: first option, #5: second option + \tl_if_blank:nF { #2#4#6 } + { + \tl_if_empty:nTF { #3 } + { \__acro_declare_citation_aux:nnnn { #1 } { } { } { #2 } } + { + \tl_if_empty:nTF { #5 } + { \__acro_declare_citation_aux:nnnn { #1 } { #3 } { } { #4 } } + { \__acro_declare_citation_aux:nnnn { #1 } { #3 } { #5 } { #6 } } + } + } + } + +\cs_new:Npn \__acro_declare_citation_aux:nnnn #1#2#3#4 + { + \prop_put:Nnn \l__acro_citation_prop { #1 } { #4 } + \tl_if_empty:nF { #2 } + { \prop_put:Nnn \l__acro_citation_pre_prop { #1 } { #2 } } + \tl_if_empty:nF { #3 } + { \prop_put:Nnn \l__acro_citation_post_prop { #1 } { #3 } } + } + +% -------------------------------------------------------------------------- +% the keys of \DeclareAcronym +\keys_define:nn { acro / declare-acronym } + { + short .code:n = + \__acro_declare_short:Vn \l__acro_current_key_tl { #1 } , + short-plural .code:n = + \__acro_declare_short_plural:Vn \l__acro_current_key_tl { #1 } , + alt .code:n = + \__acro_declare_alt:Vn \l__acro_current_key_tl { #1 } , + long .code:n = + \__acro_declare_long:Vn \l__acro_current_key_tl { #1 } , + long-plural .code:n = + \__acro_declare_long_plural:Vn \l__acro_current_key_tl { #1 } , + long-plural-form .code:n = + \__acro_declare_long_plural_form:Vn \l__acro_current_key_tl { #1 } , + sort .code:n = + \__acro_declare_sort:Vn \l__acro_current_key_tl { #1 } , + extra .code:n = + \__acro_declare_extra:Vn \l__acro_current_key_tl { #1 } , + format .code:n = + \__acro_declare_format:Vn \l__acro_current_key_tl { #1 } , + class .code:n = + \__acro_declare_class:Vn \l__acro_current_key_tl { #1 } , + cite .code:n = + \exp_args:NV + \__acro_declare_citation:nw \l__acro_current_key_tl #1 [][] \scan_stop: \acro_stop: , + pdfstring .code:n = + \exp_args:NV + \__acro_declare_pdfstring:nw \l__acro_current_key_tl #1 // \acro_stop: , + accsupp .code:n = + \__acro_declare_acc_supp:Vn \l__acro_current_key_tl { #1 } + } + +\cs_new:Npn \acro_define_acronym_macro:n #1 + { + \bool_if:NT \l__acro_create_macros_bool + { + \cs_if_exist:cTF { #1 } + { + \bool_if:NT \l__acro_strict_bool + { \cs_set:cpn { #1 } { \ac { #1 } \acro_xspace: } } + } + { \cs_new:cpn { #1 } { \ac { #1 } \acro_xspace: } } + } + } + +% -------------------------------------------------------------------------- +% internal acronym declaring function: +\cs_new:Npn \acro_declare_acronym:nn #1#2 + { + \tl_set:Nn \l__acro_current_key_tl { #1 } + \keys_set:nn { acro / declare-acronym } { #2 } + \bool_new:c { g__acro_#1_used_bool } + \bool_new:c { g__acro_#1_label_bool } + \acro_create_page_records:n { #1 } + \acro_define_acronym_macro:n { #1 } + \tl_clear:N \l__acro_current_key_tl + \bool_if:cF { l__acro_short_#1_set_bool } + { \msg_error:nnxx { acro } { missing } { #1 } { short } } + \bool_if:cF { l__acro_long_#1_set_bool } + { \msg_error:nnxx { acro } { missing } { #1 } { long } } + } + +% -------------------------------------------------------------------------- +% the user command: +\NewDocumentCommand \DeclareAcronym { mm } + { \acro_declare_acronym:nn { #1 } { #2 } } +\@onlypreamble\DeclareAcronym + +% -------------------------------------------------------------------------- +% print the list: +% #1: list of classes +% #2: list of excluded classes +\tl_new:N \l__acro_included_classes_tl +\tl_new:N \l__acro_excluded_classes_tl + +\cs_new: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 , + exclude-classes .tl_set:N = \l__acro_excluded_classes_tl , + name .tl_set:N = \l__acro_list_name_tl , + header .tl_set:N = \l__acro_list_title_tl + } + +\cs_new:Npn \acro_print_acronyms:n #1 + { + \tl_clear:N \l__acro_included_classes_tl + \tl_clear:N \l__acro_excluded_classes_tl + \keys_set:nn { acro / print-acronyms } { #1 } + \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 } + \cs_if_exist:NTF \acro@printed@list + { + \acro_use_list_instance:VV + \l__acro_included_classes_tl + \l__acro_excluded_classes_tl + } + { \@latex@warning@no@line {Rerun~to~get~acronym~list~right} } + } + +\NewDocumentCommand \printacronyms { O{} } + { \acro_print_acronyms:n { #1 } } +\tex_endinput:D
\ No newline at end of file |