diff options
author | Karl Berry <karl@freefriends.org> | 2013-01-29 23:21:06 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-01-29 23:21:06 +0000 |
commit | 13bacf6392e96e4d46c40e1d4b50b9e70055fb18 (patch) | |
tree | 8fdf13d699623afeebe235c54bfbd8dfe7d61d58 /Master | |
parent | 86f4995eee505ffb07f244911a667873bba1468c (diff) |
acro (29jan13)
git-svn-id: svn://tug.org/texlive/trunk@28981 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/acro/README | 4 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/acro/acro_en.pdf | bin | 471647 -> 477770 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/acro/acro_en.tex | 159 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/acro/acro.sty | 347 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/acro/acro1.def | 135 |
5 files changed, 483 insertions, 162 deletions
diff --git a/Master/texmf-dist/doc/latex/acro/README b/Master/texmf-dist/doc/latex/acro/README index ae974b44b72..72fbe67ebe4 100644 --- a/Master/texmf-dist/doc/latex/acro/README +++ b/Master/texmf-dist/doc/latex/acro/README @@ -1,9 +1,9 @@ -------------------------------------------------------------------------- -the ACRO package v1.0 +the ACRO package v1.1a Typeset Acronyms -2013/01/16 +2013/01/29 -------------------------------------------------------------------------- Clemens Niederberger Web: https://bitbucket.org/cgnieder/acro/ diff --git a/Master/texmf-dist/doc/latex/acro/acro_en.pdf b/Master/texmf-dist/doc/latex/acro/acro_en.pdf Binary files differindex fabcc34ad36..265ffa032a2 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 72c4fe55d40..7eaa8baf26e 100644 --- a/Master/texmf-dist/doc/latex/acro/acro_en.tex +++ b/Master/texmf-dist/doc/latex/acro/acro_en.tex @@ -40,7 +40,7 @@ % \documentclass[DIV10,toc=index,toc=bib,hyperfootnotes=false]{cnpkgdoc} \docsetup{ - pkg = {[single,macros,accsupp]acro} , + pkg = {[single,macros,accsupp,index]acro} , language = en , code-box = { backgroundcolor = gray!7!white , @@ -165,30 +165,30 @@ \newcommand*\h[1]{\textcolor{main}{\textbf{#1}}} \ExplSyntaxOn -\NewDocumentCommand \Default {g} +\NewDocumentCommand \Default {sg} { \hfill\llap { - \IfNoValueTF { #1 } + \IfNoValueTF { #2 } {(initially~empty)} - {Default:~\code{#1}} + {Default:~\code{#2}} } - \newline + \IfBooleanF { #1 } { \newline } } \ExplSyntaxOff % declare acronyms \DeclareAcronym{cd} { - short = cd , - long = Compact Disc , - format = \scshape + short = cd , + long = Compact Disc , + short-format = \scshape } \DeclareAcronym{id} { - short = id , - long = identification string , - format = \scshape + short = id , + long = identification string , + short-format = \scshape } \DeclareAcronym{jpg} { @@ -212,10 +212,10 @@ } \DeclareAcronym{nato} { - short = nato , - long = North Atlantic Treaty Organization , - extra = \emph{deutsch}: Organisation des Nordatlantikvertrags , - format = \scshape + short = nato , + long = North Atlantic Treaty Organization , + extra = \emph{deutsch}: Organisation des Nordatlantikvertrags , + short-format = \scshape } \DeclareAcronym{ny} { @@ -228,9 +228,9 @@ } \DeclareAcronym{ot} { - short = ot , - long = Other Test , - format = \scshape + short = ot , + long = Other Test , + short-format = \scshape } \DeclareAcronym{pdf} { @@ -365,36 +365,75 @@ one command with only two arguments. 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} + %% short \Option{short}{<text>}\newline the short form of the acronym. + %% long \Option{long}{<text>}\newline the long form of the acronym. + %% short-plural \Option{short-plural}{<text>}\Default{s} the plural ending appended to the short form. + %% long-plural \Option{long-plural}{<text>}\Default{s} the plural ending appended to the long form. + %% long-plural-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. + %% long-pre + \Option{long-pre}{<text>}\newline + \sinceversion{1.1}\code{<text>} is prepended to the long form in the text but + not in the list of acronyms. + %% long-post + \Option{long-post}{<text>}\newline + \sinceversion{1.1}\code{<text>} is appended to the long form in the text but + not in the list of acronyms. + %% alt \Option{alt}{<text>}\newline alternative short form. + %% extra \Option{extra}{<text>}\newline extra information to be added in the list of acronyms. + %% sort \Option{sort}{<text>}\newline if used the acronym will be sorted according to this key instead of its \acs{id}. + %% class \Option{class}{<text>}\newline the class the acronym belongs to. + %% cite \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 + %% short-format + \Option{short-format}{<\TeX{} code>}\newline the format used for the short form of the acronym. + %% long-format + \Option{long-format}{<\TeX{} code>}\newline + the format used for the long form of the acronym. + %% pdfstring \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. + %% accsupp \Option{accsupp}{<text>}\newline sets the \code{ActualText} key as presented by the \paket*{accsupp} package for the acronym. + %% index-sort + \Option{index-sort}{<text>}\newline + \sinceversion{1.1}If you use the package option \key{index} every occurrence + of an acronym is recorded to the index and sorted by its \ac{id} or (if set) + by the value of the \key{sort} key. This key allows to set an individual + sorting option for the index. See section~\ref{ssec:index} for details. + %% index + \Option{index}{<text>}\newline + \sinceversion{1.1}This key allows to overwrite the automatic index entry with + an arbitrary one. See section~\ref{ssec:index} for details. + %% index-cmd + \Option{index-cmd}{<text>}\newline + \sinceversion{1.1}This key let's you set an individual index creating command + for this acronym. It should be a command that takes one mandatory argument. + See section~\ref{ssec:index} for details. \end{beschreibung} In its simplest form an acronym needs a short and a long form. Please note that @@ -415,9 +454,9 @@ an acronym: \begin{beispiel}[code only] % preamble: \DeclareAcronym{ot}{ - short = ot , - long = Other Test , - format = \scshape + short = ot , + long = Other Test , + short-format = \scshape } \end{beispiel} The short form now looks like this: \acs{ot}. @@ -495,9 +534,9 @@ since then the appearance in the table of contents won't mark it as used. \begin{beispiel} % preamble: % \DeclareAcronym{cd}{ - % short = cd , - % long = Compact Disc , - % format = \scshape + % short = cd , + % long = Compact Disc , + % short-format = \scshape % } first time: \ac{cd} \\ second time: \ac{cd} \\ @@ -529,9 +568,9 @@ plural form when necessary. Suppose we define the following acronyms: \begin{beispiel}[code only] \DeclareAcronym{cd}{ - short = cd , - long = Compact Disc , - format = \scshape + short = cd , + long = Compact Disc , + short-format = \scshape } \DeclareAcronym{ny}{ short = NY , @@ -590,10 +629,10 @@ for the impact of the following example. \begin{beispiel} % preamble: % \DeclareAcronym{nato}{ - % short = nato , - % long = North Atlantic Treaty Organization , - % extra = \textit{deutsch}: Organisation des Nordatlantikvertrags , - % format = \scshape + % short = nato , + % long = North Atlantic Treaty Organization , + % extra = \textit{deutsch}: Organisation des Nordatlantikvertrags , + % short-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} @@ -611,7 +650,7 @@ For this \cmd{DeclareAcronym} has an additional key: \begin{beschreibung} \Option{class}{<text>} \end{beschreibung} -\begin{beispiel} +\begin{beispiel}[below] % preamble: % \DeclareAcronym{la}{ % short = LA , @@ -699,6 +738,25 @@ 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. +\subsection{Adding Acronyms to the Index}\label{ssec:index} +\secidx[indexing]{Additional Commands} +\noindent\sinceversion{1.1}\acro has the package option \key{index}. If it is +used an index entry will be recorded every time an \emph{unstarred} acronym +command is used. The index entry will be \code{<id>@<short>}, \code{<sort>@<short>} +if the \key{sort} key has been set, \code{<index-sort>@<short>}if the +\key{index-sort} has been set, or \code{<index>} if the key \key{index} has been +set for the specific acronym. The short version appearing there are formatted +according to the chosen format, of course. + +This document demonstrates the feature. You can find every acronym that has been +declared in the index. In order to allow flexibility the indexing command can be +chosen both globally via package option and individually for every acronym. This +would allow to add acronyms to a specific index if more than one index is used, +for example with help of the \paket{imakeidx} package. + +I'm not yet convinced this is a feature many people if anyone needs and if they +do if it is flexible enough. If you have any thoughts on this I'd appreciate an +email. \secidx*{Additional Commands} \section{Printing the List}\label{sec:print_lists}\secidx{Printing the List} @@ -740,7 +798,7 @@ need at least two runs and often are compiled much more often than that, this fact shouldn't cause too much inconvenience. \secidx*{Printing the List} -\section{Customization}\label{sec:customization}\secidx{Customization} +\section{Options and Customization}\label{sec:customization}\secidx{Customization} \subsection{General Options}\secidx[general options]{Customization} There are a few options which change the general behaviour of \acro. \default{Underlined} values are used if no value is given. @@ -805,6 +863,15 @@ There are a few options which change the general behaviour of \acro. set this. Actually it can be used to place arbitrary code right before the citation.\catcode`\_=11 %% + \Option{index}{\default{true}|false}\Default{false} + \sinceversion{1.1}If set to \code{true} an index entry will be recorded + every time an \emph{unstarred} acronym command is used for the corresponding + acronym. + %% + \Option{index-cmd}{<cmd>}\Default{\cmd*{index}} + \sinceversion{1.1}Chooses the index command that is used when option \key{index} + has been set to \code{true}. + %% \Option{accsupp}{\default{true}|false}\Default{false} \sinceversion{1.0}Activates the access support as provided by the \paket{accsupp} package. @@ -840,16 +907,24 @@ possible output forms of the acronyms. \Option{long-format}{<format>}\Default The same for the long forms. %% + \Option{list-short-format}{<format>}\Default + \sinceversion{1.1}An extra format for the short entries in the list. If not + used this is the same as \key{short-format}. Please be aware that a call of + \key{short-format} after this one will overwrite it again. + %% \Option{list-long-format}{<format>}\Default An extra format for the long entries in the list. If not used this is the same - as \key{long-format}. + as \key{long-format}. Please be aware that a call of \key{long-format} after + this one will overwrite it again. %% \Option{extra-format}{<format>}\Default The same for the extra information. %% - \Option{first-style}{default|plain|footnote|square|short|reversed|plain-reversed}\\ - \null\Default{default} - The basic style of the first appearance of an acronym. + \Option{first-style}{default|plain|empty|square|short|reversed|plain-reversed|\\ + footnote|sidenote}\Default{default} + \changedversion{1.1}The basic style of the first appearance of an acronym. + The value \code{sidenote} needs the command \cmd*{sidenote} to be defined for + example by the \paket{sidenotes} package. %% \Option{extra-style}{default|plain|comma|paren|bracket}\Default{default} Defines the way the extra information is printed in the list. @@ -861,6 +936,8 @@ possible output forms of the acronyms. \begin{beispiel} % (Keep in mind that we're in % a minipage here!) + \acsetup{first-style=empty} + \acf{ny} \\ \acsetup{first-style=footnote} \acf{ny} \\ \acsetup{first-style=square} @@ -923,8 +1000,10 @@ possible output forms of the acronyms. The values \code{extra-longtable} and \code{extra-longtable-rev} put the extra information in a column of its own. %% - \Option{list-header}{chapter|chapter*|section|section*|subsection|subsection*}\\ - The header type of the list.\Default{section*} + \Option{list-header}{chapter|chapter*|section|section*|subsection|subsection*|\\ + addchap|addsec}\Default{section*} + \changedversion{1.1}The header type of the list. The last two only work with + a \KOMAScript{} class that also defines the appropriate command. %% \Option{list-name}{<list name>}\Default{Acronyms} The name of the list. This is what's written in the list-header. This is diff --git a/Master/texmf-dist/tex/latex/acro/acro.sty b/Master/texmf-dist/tex/latex/acro/acro.sty index fb8b8c09105..af47b4d9740 100644 --- a/Master/texmf-dist/tex/latex/acro/acro.sty +++ b/Master/texmf-dist/tex/latex/acro/acro.sty @@ -31,8 +31,8 @@ \RequirePackage{expl3,xparse,l3keys2e,xtemplate} \ProvidesExplPackage {acro} - {2013/01/16} - {1.0} + {2013/01/29} + {1.1a} {Typeset Acronyms} % warning and error messages: @@ -85,9 +85,11 @@ \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 +\bool_new:N \l__acro_addto_index_bool % tokenlist variables: \tl_new:N \l__acro_short_format_tl +\tl_new:N \l__acro_list_short_format_tl \tl_new:N \l__acro_long_format_tl \tl_new:N \l__acro_list_long_format_tl \tl_new:N \l__acro_extra_format_tl @@ -119,6 +121,8 @@ \tl_set:Nn \l__acro_default_plural_tl { s } \tl_new:N \l__acro_alt_tl \tl_new:N \l__acro_long_tl +\tl_new:N \l__acro_long_pre_tl +\tl_new:N \l__acro_long_post_tl \tl_new:N \l__acro_custom_format_tl \tl_new:N \l__acro_first_between_tl \tl_new:N \l__acro_citation_space_tl @@ -133,14 +137,20 @@ \prop_new:N \l__acro_replace_plural_prop \prop_new:N \l__acro_short_plural_prop \prop_new:N \l__acro_long_plural_prop +\prop_new:N \l__acro_long_pre_prop +\prop_new:N \l__acro_long_post_prop \prop_new:N \l__acro_extra_prop \prop_new:N \l__acro_format_prop +\prop_new:N \l__acro_long_format_prop \prop_new:N \l__acro_citation_prop \prop_new:N \l__acro_citation_pre_prop \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 +\prop_new:N \l__acro_index_prop +\prop_new:N \l__acro_index_sort_prop +\prop_new:N \l__acro_index_cmd_prop % length variables: \dim_new:N \l__acro_table_width_dim @@ -148,6 +158,7 @@ \cs_new:Npn \__acro_citation_cmd:w { \cite } \cs_new:Npn \__acro_no_break: { \tex_penalty:D \c_ten_thousand } +\cs_new:Npn \__acro_index_cmd:n { \index } \cs_new:Npn \__acro_first_upper_case:n #1 { \tl_expandable_uppercase:n { \tl_head:n { #1 } } \tl_tail:n { #1 } } @@ -185,52 +196,58 @@ % 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 , - sort .bool_set:N = \l__acro_sort_bool , - short-format .tl_set:N = \l__acro_short_format_tl , - long-format .code:n = + 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 , + sort .bool_set:N = \l__acro_sort_bool , + short-format .code:n = + \tl_set:Nn \l__acro_short_format_tl { #1 } + \tl_set:Nn \l__acro_list_short_format_tl { #1 } , + long-format .code:n = \tl_set:Nn \l__acro_long_format_tl { #1 } - \tl_set:Nn \l__acro_list_long_format_tl { #1 } , - list-long-format .tl_set:N = \l__acro_list_long_format_tl , - extra-format .tl_set:N = \l__acro_extra_format_tl , - single .bool_set:N = \l__acro_use_single_bool , - first-style .tl_set:N = \l__acro_first_instance_tl , - 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 , - list-name .tl_set:N = \l__acro_list_name_tl , - list-table-width .dim_set:N = \l__acro_table_width_dim , - hyperref .bool_set:N = \l__acro_use_hyperref_bool , - only-used .bool_set:N = \l__acro_print_only_used_bool , - plural-ending .tl_set:N = \l__acro_default_plural_tl , - list-caps .bool_set:N = \l__acro_capitalize_list_bool , - cite .choice: , - cite / all .code:n = + \tl_set:Nn \l__acro_list_long_format_tl { #1 } , + list-short-format .tl_set:N = \l__acro_list_short_format_tl , + list-long-format .tl_set:N = \l__acro_list_long_format_tl , + extra-format .tl_set:N = \l__acro_extra_format_tl , + single .bool_set:N = \l__acro_use_single_bool , + first-style .tl_set:N = \l__acro_first_instance_tl , + 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 , + list-name .tl_set:N = \l__acro_list_name_tl , + list-table-width .dim_set:N = \l__acro_table_width_dim , + hyperref .bool_set:N = \l__acro_use_hyperref_bool , + only-used .bool_set:N = \l__acro_print_only_used_bool , + plural-ending .tl_set:N = \l__acro_default_plural_tl , + list-caps .bool_set:N = \l__acro_capitalize_list_bool , + cite .choice: , + cite / all .code:n = \bool_set_true:N \l__acro_citation_all_bool - \bool_set_true:N \l__acro_citation_first_bool , - cite / none .code:n = + \bool_set_true:N \l__acro_citation_first_bool , + cite / none .code:n = \bool_set_false:N \l__acro_citation_all_bool - \bool_set_false:N \l__acro_citation_first_bool , - cite / first .code:n = + \bool_set_false:N \l__acro_citation_first_bool , + cite / first .code:n = \bool_set_false:N \l__acro_citation_all_bool - \bool_set_true:N \l__acro_citation_first_bool , - cite-all .default:n = all , - cite-cmd .code:n = - \cs_set:Npn \__acro_citation_cmd:w { #1 } , - cite-space .tl_set:N = \l__acro_citation_space_tl , - uc-cmd .code:n = + \bool_set_true:N \l__acro_citation_first_bool , + cite-all .default:n = all , + cite-cmd .code:n = + \cs_set:Npn \__acro_citation_cmd:w { #1 } , + cite-space .tl_set:N = \l__acro_citation_space_tl , + index .bool_set:N = \l__acro_addto_index_bool , + index-cmd .code:n = + \cs_set:Npn \__acro_index_cmd:n { #1 } , + uc-cmd .code:n = \cs_set_eq:NN \__acro_first_upper_case:n #1 } @@ -245,7 +262,7 @@ } { \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 } + { \cs_set_eq:NN \acro_record_page_number:n \use_none:n } } % setup command: @@ -268,16 +285,23 @@ \cs_generate_variant:Nn \__acro_write_short:n { V } % typeset the longform,...: +% TODO: rethink the formatting mechanism +% right now a custom format gets applied additionally to the global one +% although before it \cs_new:Npn \__acro_write_long:Nn #1#2 { \mode_if_horizontal:F { \leavevmode } \group_begin: - \exp_args:Nx #1 - { - \bool_if:NTF \l__acro_first_upper_bool - { \exp_not:N \__acro_first_upper_case:n { \exp_not:n { #2 } } } - { \exp_not:n { #2 } } - } + \bool_if:NT \l__acro_custom_long_format_bool + { \l__acro_custom_long_format_tl } + { + \exp_args:Nx #1 + { + \bool_if:NTF \l__acro_first_upper_bool + { \exp_not:N \__acro_first_upper_case:n { \exp_not:n { #2 } } } + { \exp_not:n { #2 } } + } + } \group_end: } \cs_generate_variant:Nn \__acro_write_long:Nn { NV,No,Nf } @@ -340,14 +364,19 @@ \bool_new:N \l__acro_first_use_brackets_bool \bool_new:N \l__acro_first_only_short_bool \bool_new:N \l__acro_first_reversed_bool +\bool_new:N \l__acro_use_note_bool + \tl_new:N \l__acro_first_brackets_tl +\cs_new:Npn \__acro_note_command:n #1 { #1 } + % #1: id % #2: short % #3: long \DeclareObjectType { acro-first } { 3 } -\DeclareTemplateInterface { acro-first } { text } { 3 } +% template for inline appearance: +\DeclareTemplateInterface { acro-first } { inline } { 3 } { brackets : boolean = true , brackets-type : tokenlist = () , @@ -355,7 +384,7 @@ reversed : boolean = false , between : tokenlist , } -\DeclareTemplateCode { acro-first } { text } { 3 } +\DeclareTemplateCode { acro-first } { inline } { 3 } { brackets = \l__acro_first_use_brackets_bool , brackets-type = \l__acro_first_brackets_tl , @@ -375,12 +404,15 @@ \tl_use:N \c_space_tl } } - \bool_if:nT { \l__acro_first_use_brackets_bool && !\l__acro_first_reversed_bool } + \bool_if:nT + { \l__acro_first_use_brackets_bool && !\l__acro_first_reversed_bool } { \tl_head:N \l__acro_first_brackets_tl } \__acro_acc_supp:nn { #1 } { \__acro_write_short:n { #2 } } - \bool_if:nT { \l__acro_first_use_brackets_bool && !\l__acro_first_reversed_bool } + \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 } + \bool_if:nT + { !\l__acro_first_only_short_bool && \l__acro_first_reversed_bool } { \tl_if_blank:VF \l__acro_first_between_tl { @@ -388,39 +420,88 @@ \tl_use:N \l__acro_first_between_tl } \tl_use:N \c_space_tl - \bool_if:nT { \l__acro_first_use_brackets_bool && \l__acro_first_reversed_bool } + \bool_if:nT + { \l__acro_first_use_brackets_bool && \l__acro_first_reversed_bool } { \tl_head:N \l__acro_first_brackets_tl } \__acro_write_long:No \l__acro_long_format_tl { #3 } - \bool_if:nT { \l__acro_first_use_brackets_bool && \l__acro_first_reversed_bool } + \bool_if:nT + { \l__acro_first_use_brackets_bool && \l__acro_first_reversed_bool } { \tl_tail:N \l__acro_first_brackets_tl } } - \__acro_cite_if:Nn \l__acro_citation_first_bool { #1 } + \acro_after:n { #1 } + } + +% template for footnotes, sidenotes, ... +\DeclareTemplateInterface { acro-first } { note } { 3 } + { + use-note : boolean = true , + note-command : function 1 = \footnote { #1 } } -\DeclareTemplateInterface { acro-first } { footnote } { 3 } { } -\DeclareTemplateCode { acro-first } { footnote } { 3 } { } +\DeclareTemplateCode { acro-first } { note } { 3 } + { + use-note = \l__acro_use_note_bool , + note-command = \__acro_note_command:n + } { \AssignTemplateKeys \__acro_acc_supp:nn { #1 } { \__acro_write_short:n { #2 } } - \footnote + \bool_if:NT \l__acro_use_note_bool { - \__acro_write_long:No \l__acro_long_format_tl { #3 } - \__acro_cite_if:Nn \l__acro_citation_first_bool { #1 } - } + \__acro_note_command:n + { + \__acro_write_long:No \l__acro_long_format_tl { #3 } + \__acro_cite_if:Nn \l__acro_citation_first_bool { #1 } + } + } } % the different styles: -\DeclareInstance { acro-first } { default } { text } { } -\DeclareInstance { acro-first } { square } { text } +\DeclareInstance { acro-first } + { default } + { inline } + { } +\DeclareInstance { acro-first } + { square } + { inline } { brackets-type = [] } -\DeclareInstance { acro-first } { plain } { text } - { brackets = false , between = -- } -\DeclareInstance { acro-first } { plain-reversed } { text } - { brackets = false , between = -- , reversed = true } -\DeclareInstance { acro-first } { footnote } { footnote } { } -\DeclareInstance { acro-first } { short } { text } - { only-short = true , brackets = false } -\DeclareInstance { acro-first } { reversed } { text } +\DeclareInstance { acro-first } + { plain } + { inline } + { + brackets = false , + between = -- + } +\DeclareInstance { acro-first } + { plain-reversed } + { inline } + { + brackets = false , + between = -- , + reversed = true + } +\DeclareInstance { acro-first } + { footnote } + { note } + { } +\DeclareInstance { acro-first } + { sidenote } + { note } + { note-command = \sidenote { #1 } } +\DeclareInstance { acro-first } + { empty } + { note } + { use-note = false } +\DeclareInstance { acro-first } + { short } + { inline } + { + only-short = true , + brackets = false + } +\DeclareInstance { acro-first } + { reversed } + { inline } { reversed = true } % -------------------------------------------------------------------------- @@ -535,7 +616,7 @@ } \cs_generate_variant:Nn \__acro_convert_to_arabic:n { V } -\cs_new:Npn \__acro_record_page_number:n #1 +\cs_new:Npn \acro_record_page_number:n #1 { \seq_if_empty:cTF { g__acro_#1_pages_seq } {% no pages recorded, yet @@ -779,6 +860,10 @@ { name-format = \section { #1 } } \DeclareInstance { acro-title } { subsection } { sectioning } { name-format = \subsection { #1 } } +\DeclareInstance { acro-title } { addchap } { sectioning } + { name-format = \addchap { #1 } } +\DeclareInstance { acro-title } { addsec } { sectioning } + { name-format = \addsec { #1 } } % -------------------------------------------------------------------------- % outputting the whole list @@ -879,7 +964,11 @@ [ \acro_hyper_target:nn { ##1 } - { \__acro_acc_supp:nn { ##1 } { \__acro_write_short:n { ##2 } } } + { + \__acro_acc_supp:nn + { ##1 } + { \__acro_write_short:n { \l__acro_list_short_format_tl { ##2 } } } + } ] } \cs_set:Npn \acro_print_list_long:n ##1 @@ -928,7 +1017,11 @@ { \acro_hyper_target:nn { ##1 } - { \__acro_acc_supp:nn { ##1 } { \__acro_write_short:n { ##2 } } } + { + \__acro_acc_supp:nn + { ##1 } + { \__acro_write_short:n { \l__acro_list_short_format_tl { ##2 } } } + } & } \cs_set:Npn \acro_print_list_long:n ##1 @@ -975,7 +1068,11 @@ { \acro_hyper_target:nn { ##1 } - { \__acro_acc_supp:nn { ##1 } { \__acro_write_short:n { ##2 } } } + { + \__acro_acc_supp:nn + { ##1 } + { \__acro_write_short:n { \l__acro_list_short_format_tl { ##2 } } } + } & } \cs_set:Npn \acro_print_list_long:n ##1 @@ -1078,14 +1175,13 @@ { % get the acronym and the plural settings: \acro_get:n { #1 } - \acro_set_plural:n { #1 } \acro_is_used:nTF { #1 } { % this is not the first time \__acro_acc_supp:nn { #1 } { \__acro_write_short:V \l__acro_short_tl } - \__acro_cite_if:Nn \l__acro_citation_all_bool { #1 } + \acro_after:n { #1 } } { % this is the first time @@ -1127,24 +1223,29 @@ \__acro_make_link:nNN { #1 } \l__acro_short_tl \l__acro_tmpa_tl \prop_get:NnN \l__acro_short_plural_prop { #1 } \l__acro_short_plural_tl \prop_get:NnN \l__acro_long_prop { #1 } \l__acro_long_tl + \prop_get:NnNTF \l__acro_long_format_prop { #1 } \l__acro_custom_long_format_tl + { \bool_set_true:N \l__acro_custom_long_format_bool } + { \bool_set_false:N \l__acro_custom_long_format_bool } + \prop_get:NnNT \l__acro_long_pre_prop { #1 } \l__acro_long_pre_tl + { \tl_put_left:NV \l__acro_long_tl \l__acro_long_pre_tl } \prop_get:NnN \l__acro_alt_prop { #1 } \l__acro_tmpb_tl \__acro_make_link:nNN { #1 } \l__acro_alt_tl \l__acro_tmpb_tl \prop_get:NnNTF \l__acro_format_prop { #1 } \l__acro_custom_format_tl { \bool_set_true:N \l__acro_custom_format_bool } { \bool_set_false:N \l__acro_custom_format_bool } + \__acro_set_plural:n { #1 } + \prop_get:NnNT \l__acro_long_post_prop { #1 } \l__acro_long_post_tl + { \tl_put_right:NV \l__acro_long_tl \l__acro_long_post_tl } } \cs_generate_variant:Nn \tl_put_right:Nn { NV } -\cs_new:Npn \acro_set_plural:n #1 +\cs_new:Npn \__acro_set_plural:n #1 { \bool_if:NT \l__acro_use_plural_bool { \bool_if:nTF { \prop_get:Nn \l__acro_replace_plural_prop { #1 } } - { - \prop_get:NnN \l__acro_short_plural_prop { #1 } \l__acro_alt_tl - \prop_get:NnN \l__acro_long_plural_prop { #1 } \l__acro_long_tl - } + { \prop_get:NnN \l__acro_long_plural_prop { #1 } \l__acro_long_tl } { \tl_put_right:Nn \l__acro_long_tl { \prop_get:Nn \l__acro_long_plural_prop { #1 } } @@ -1197,51 +1298,53 @@ } % -------------------------------------------------------------------------- +\cs_new:Npn \acro_after:n #1 + { + \__acro_cite_if:Nn \l__acro_citation_all_bool { #1 } + \__acro_index_if:Nn \l__acro_addto_index_bool { #1 } + } + % the standard internals: \cs_new:Npn \acro_short:n #1 { \acro_get:n { #1 } - \acro_set_plural:n { #1 } \acro_is_used:n { #1 } \__acro_is_single:nT { #1 } { \cs_set_eq:NN \acro_hyper_link:nn \use_ii:nn } \__acro_acc_supp:nn { #1 } { \__acro_write_short:V \l__acro_short_tl } - \__acro_cite_if:Nn \l__acro_citation_all_bool { #1 } + \acro_after:n { #1 } } % get alternative entry: \cs_new:Npn \acro_alt:n #1 { \acro_get:n { #1 } - \acro_set_plural:n { #1 } \acro_is_used:n { #1 } \__acro_is_single:nT { #1 } { \cs_set_eq:NN \acro_hyper_link:nn \use_ii:nn } \__acro_acc_supp:nn { #1 } { \__acro_write_short:V \l__acro_alt_tl } - \__acro_cite_if:Nn \l__acro_citation_all_bool { #1 } + \acro_after:n { #1 } } % get long entry: \cs_new:Npn \acro_long:n #1 { \acro_get:n { #1 } - \acro_set_plural:n { #1 } \acro_is_used:n { #1 } \__acro_is_single:nT { #1 } { \cs_set_eq:NN \acro_hyper_link:nn \use_ii:nn } \__acro_write_long:NV \l__acro_long_format_tl \l__acro_long_tl - \__acro_cite_if:Nn \l__acro_citation_all_bool { #1 } + \acro_after:n { #1 } } % output like the first time: \cs_new:Npn \acro_first:n #1 { \acro_get:n { #1 } - \acro_set_plural:n { #1 } \acro_is_used:n { #1 } \__acro_is_single:nT { #1 } { \cs_set_eq:NN \acro_hyper_link:nn \use_ii:nn } @@ -1251,6 +1354,8 @@ { \l__acro_long_tl } } +% ---------------------------------------------------------------------------- +% citations: % #1 pre % #2 post % #3 key @@ -1284,6 +1389,48 @@ } } +% ---------------------------------------------------------------------------- +% indexing: +\cs_new:Npn \__acro_index_if:Nn #1#2 + { + \bool_if:nT { #1 && \l__acro_mark_as_used_bool } + { + \prop_get:NnN \l__acro_index_cmd_prop { #2 } \l__acro_tmpa_tl + \prop_get:NnN \l__acro_index_sort_prop { #2 } \l__acro_tmpb_tl + \prop_get:NnN \l__acro_index_prop { #2 } \l__acro_tmpc_tl + \__acro_index:VnVV + \l__acro_tmpa_tl + { #2 } + \l__acro_tmpb_tl + \l__acro_tmpc_tl + } + } + +% #1: cmd +% #2: key +% #3: sort +% #4: replace +\cs_new:Npn \__acro_index:nnnn #1#2#3#4 + { + \prop_get:NnN \l__acro_short_prop { #2 } \l__acro_tmpa_tl + \prop_get:NnN \l__acro_format_prop { #2 } \l__acro_tmpb_tl + \quark_if_no_value:VTF \l__acro_tmpb_tl + { \tl_set:Nn \l__acro_tmpc_tl { \l__acro_short_format_tl \l__acro_tmpa_tl } } + { \tl_set:Nn \l__acro_tmpc_tl { \l__acro_tmpb_tl \l__acro_tmpa_tl } } + \quark_if_no_value:nF { #1 } + { \cs_set:Npn \__acro_index_cmd:n { #1 } } + \quark_if_no_value:nTF { #4 } + { + \quark_if_no_value:nTF { #3 } + { \__acro_index_cmd:n { #2 @ { \l__acro_tmpc_tl } } } + { \__acro_index_cmd:n { #3 @ { \l__acro_tmpc_tl } } } + } + { \__acro_index_cmd:n { #4 } } + } +\cs_generate_variant:Nn \__acro_index:nnnn { VnVV } +\cs_generate_variant:Nn \quark_if_no_value:nTF { V } + +% ---------------------------------------------------------------------------- % accessability support \tl_new:N \l__acro_acc_supp_tl \cs_new_eq:NN \__acro_acc_supp:nn \use_ii:nn @@ -1359,13 +1506,12 @@ \cs_new:Npn \acro@print@list { \cs_if_exist:NF \acro@printed@list { \cs_new:Npn \acro@printed@list {} } } - \cs_new:Npn \acro_use_if:nn #1#2 { \IfBooleanTF { #1 } { \bool_set_false:N \l__acro_mark_as_used_bool } { - \__acro_record_page_number:n { #2 } + \acro_record_page_number:n { #2 } \bool_set_true:N \l__acro_mark_as_used_bool } } @@ -1708,10 +1854,21 @@ `pages-name', `record-pages' - no automatic label placement for page number referencing any more +2013/01/26 v1.1 - bug fix in the plural detection + - new keys `long-pre' and `long-post' + - new keys `index', `index-sort' and `index-cmd' + - new options `index' and `index-cmd' +2013/01/29 v1.1a - added `long-format' key + - renamed `format' key into `short-format', kept `format' for + compatibility reasons % -------------------------------------------------------------------------- % TODO: - Option `totoc'!? +- Optionen `list-header = addsec|addchap' (acro-title instance) +- acro-first instance `none', die nur die Kurzform verwendet +- Option `list-short-format' + - 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 diff --git a/Master/texmf-dist/tex/latex/acro/acro1.def b/Master/texmf-dist/tex/latex/acro/acro1.def index 21d4e83fa92..f585cadbf5d 100644 --- a/Master/texmf-dist/tex/latex/acro/acro1.def +++ b/Master/texmf-dist/tex/latex/acro/acro1.def @@ -51,26 +51,33 @@ { 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 +\msg_new:nnnn { acro } { doubled-key } + { It~seems~to~me~you~have~used~the~`#1'~key~before. } + { + It~seems~to~me~you~have~used~the~`#1'~key~before.~If~you~haven't~there's~ + something~different~wrong~and~I'm~lost.~You~'re~on~your~own~now. + } + \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 } + \bool_if:cF { l__acro_#1_short_set_bool } { \msg_error:nnxx { acro } { before-short } { #1 } { #2 } } + \bool_new:c { l__acro_#1_#2_set_bool } + \bool_set_true:c { l__acro_#1_#2_set_bool } } \cs_new:Npn \__acro_first_key_check:n #1 { - \cs_if_exist:cTF { l__acro_short_#1_set_bool } + \cs_if_exist:cTF { l__acro_#1_short_set_bool } { - \bool_if:cTF { l__acro_short_#1_set_bool } - {} - { \bool_set_true:c { l__acro_short_#1_set_bool } } + \bool_if:cT { l__acro_#1_short_set_bool } + { \msg_error:nnx { acro } { doubled-key } { #1 } } } - {% error: key already used + { + \bool_new:c { l__acro_#1_short_set_bool } + \bool_set_true:c { l__acro_#1_short_set_bool } } } @@ -79,12 +86,12 @@ % 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_prop { #1 } { #2 } + \prop_put:Nnn \l__acro_sort_prop { #1 } { #1 } + \prop_put:Nnn \l__acro_index_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 @@ -103,12 +110,13 @@ \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 } + \bool_if:cF { l__acro_#1_long-plural_set_bool } + { + \prop_put:Nnn \l__acro_long_plural_prop + { #1 } { \l__acro_default_plural_tl } + } } \cs_generate_variant:Nn \__acro_declare_long:nn { V } @@ -130,11 +138,29 @@ } \cs_generate_variant:Nn \__acro_declare_long_plural_form:nn { V } +% pre long: +\cs_new:Npn \__acro_declare_long_pre:nn #1#2 + { + \__acro_key_check:nn { #1 } { long-pre } + \prop_put:Nnn \l__acro_long_pre_prop { #1 } { #2 } + } +\cs_generate_variant:Nn \__acro_declare_long_pre:nn { V } + +% post long: +\cs_new:Npn \__acro_declare_long_post:nn #1#2 + { + \__acro_key_check:nn { #1 } { long-post } + \prop_put:Nnn \l__acro_long_post_prop { #1 } { #2 } + } +\cs_generate_variant:Nn \__acro_declare_long_post: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 } + \bool_if:cF { l__acro_#1_index-sort_set_bool } + { \prop_put:Nnn \l__acro_index_sort_prop { #1 } { #2 } } } \cs_generate_variant:Nn \__acro_declare_sort:nn { V } @@ -154,6 +180,14 @@ } \cs_generate_variant:Nn \__acro_declare_format:nn { V } +% format: +\cs_new:Npn \__acro_declare_long_format:nn #1#2 + { + \__acro_key_check:nn { #1 } { long-format } + \prop_put:Nnn \l__acro_long_format_prop { #1 } { #2 } + } +\cs_generate_variant:Nn \__acro_declare_long_format:nn { V } + % pdfstring: \cs_new:Npn \__acro_declare_pdfstring:nw #1#2/#3/#4 \acro_stop: { @@ -169,6 +203,7 @@ { #1 } { \exp_not:n { #2#3 } } } } +\cs_generate_variant:Nn \__acro_declare_pdfstring:nw { V } % class: \cs_new:Npn \__acro_declare_class:nn #1#2 @@ -211,9 +246,11 @@ } } } +\cs_generate_variant:Nn \__acro_declare_citation:nw { V } \cs_new:Npn \__acro_declare_citation_aux:nnnn #1#2#3#4 { + \__acro_key_check:nn { #1 } { cite } \prop_put:Nnn \l__acro_citation_prop { #1 } { #4 } \tl_if_empty:nF { #2 } { \prop_put:Nnn \l__acro_citation_pre_prop { #1 } { #2 } } @@ -221,6 +258,42 @@ { \prop_put:Nnn \l__acro_citation_post_prop { #1 } { #3 } } } +% TODO: +% add index entries, by default \index{<sort>@<short>} +% index: overwrite default <sort>@<short> entry completely +% index-sort: overwrite the <sort> part of <sort>@<short> entry + +% need to take care of custom index cmd, at least +% - \index{} +% - \index[]{} +% question is, though, if it should be the same one for all acronyms? +% I go for yes but would also add a `post' key that allows to add arbitrary +% TeX code after an acronym is typeset + +% index: +\cs_new:Npn \__acro_declare_index:nn #1#2 + { + \__acro_key_check:nn { #1 } { index } + \prop_put:Nnn \l__acro_index_prop { #1 } { #2 } + } +\cs_generate_variant:Nn \__acro_declare_index:nn { V } + +% index-sort: +\cs_new:Npn \__acro_declare_index_sort:nn #1#2 + { + \__acro_key_check:nn { #1 } { index-sort } + \prop_put:Nnn \l__acro_index_sort_prop { #1 } { #2 } + } +\cs_generate_variant:Nn \__acro_declare_index_sort:nn { V } + +% index-cmd: +\cs_new:Npn \__acro_declare_index_cmd:nn #1#2 + { + \__acro_key_check:nn { #1 } { index-cmd } + \prop_put:Nnn \l__acro_index_cmd_prop { #1 } { #2 } + } +\cs_generate_variant:Nn \__acro_declare_index_cmd:nn { V } + % -------------------------------------------------------------------------- % the keys of \DeclareAcronym \keys_define:nn { acro / declare-acronym } @@ -237,22 +310,34 @@ \__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 } , + long-pre .code:n = + \__acro_declare_long_pre:Vn \l__acro_current_key_tl { #1 } , + long-post .code:n = + \__acro_declare_long_post: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 } , + short-format .code:n = + \__acro_declare_format:Vn \l__acro_current_key_tl { #1 } , + long-format .code:n = + \__acro_declare_long_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: , + \__acro_declare_citation:Vw \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: , + \__acro_declare_pdfstring:Vw \l__acro_current_key_tl #1 // \acro_stop: , accsupp .code:n = - \__acro_declare_acc_supp:Vn \l__acro_current_key_tl { #1 } + \__acro_declare_acc_supp:Vn \l__acro_current_key_tl { #1 } , + index .code:n = + \__acro_declare_index:Vn \l__acro_current_key_tl { #1 } , + index-sort .code:n = + \__acro_declare_index_sort:Vn \l__acro_current_key_tl { #1 } , + index-cmd .code:n = + \__acro_declare_index_cmd:Vn \l__acro_current_key_tl { #1 } } \cs_new:Npn \acro_define_acronym_macro:n #1 @@ -279,9 +364,9 @@ \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 } + \bool_if:cF { l__acro_#1_short_set_bool } { \msg_error:nnxx { acro } { missing } { #1 } { short } } - \bool_if:cF { l__acro_long_#1_set_bool } + \bool_if:cF { l__acro_#1_long_set_bool } { \msg_error:nnxx { acro } { missing } { #1 } { long } } } |