From 32ba99526f7f9324b6851487ea2c91d5cd89cbaf Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 13 Aug 2015 20:55:06 +0000 Subject: idxcmds (13aug15) git-svn-id: svn://tug.org/texlive/trunk@38115 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/idxcmds/README | 5 +- Master/texmf-dist/doc/latex/idxcmds/idxcmds_en.pdf | Bin 114643 -> 409095 bytes Master/texmf-dist/doc/latex/idxcmds/idxcmds_en.tex | 509 +++++++++------------ Master/texmf-dist/tex/latex/idxcmds/idxcmds.sty | 308 +++++++------ 4 files changed, 396 insertions(+), 426 deletions(-) (limited to 'Master') diff --git a/Master/texmf-dist/doc/latex/idxcmds/README b/Master/texmf-dist/doc/latex/idxcmds/README index 8f9f5312a0f..b4530b08618 100644 --- a/Master/texmf-dist/doc/latex/idxcmds/README +++ b/Master/texmf-dist/doc/latex/idxcmds/README @@ -1,14 +1,15 @@ -------------------------------------------------------------------------- -the IDXCMDS package v0.2b 2013/08/31 +the IDXCMDS package v0.2c 2015/08/13 create commands for adding formatted index entries -------------------------------------------------------------------------- Clemens Niederberger Web: https://bitbucket.org/cgnieder/idxcmds/ + http://www.mychemistry.eu/forums/forum/idxcmds/ E-Mail: contact@mychemistry.eu -------------------------------------------------------------------------- -Copyright 2012-2013 Clemens Niederberger +Copyright 2012-2015 Clemens Niederberger This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3 diff --git a/Master/texmf-dist/doc/latex/idxcmds/idxcmds_en.pdf b/Master/texmf-dist/doc/latex/idxcmds/idxcmds_en.pdf index 4d50199850a..77b42555e24 100644 Binary files a/Master/texmf-dist/doc/latex/idxcmds/idxcmds_en.pdf and b/Master/texmf-dist/doc/latex/idxcmds/idxcmds_en.pdf differ diff --git a/Master/texmf-dist/doc/latex/idxcmds/idxcmds_en.tex b/Master/texmf-dist/doc/latex/idxcmds/idxcmds_en.tex index a91c7b8e1f5..5a1c0218c63 100644 --- a/Master/texmf-dist/doc/latex/idxcmds/idxcmds_en.tex +++ b/Master/texmf-dist/doc/latex/idxcmds/idxcmds_en.tex @@ -1,7 +1,7 @@ -% arara: lualatex -% !arara: biber -% arara: lualatex -% !arara: lualatex +% arara: pdflatex +% arara: biber +% arara: pdflatex +% arara: pdflatex % -------------------------------------------------------------------------- % the IDXCMDS package % @@ -9,10 +9,10 @@ % % -------------------------------------------------------------------------- % Clemens Niederberger -% Web: https://bitbucket.org/cgnieder/idxcmds/ +% Web: http://www.mychemistry.eu/forums/forum/idxcmds/ % E-Mail: contact@mychemistry.eu % -------------------------------------------------------------------------- -% Copyright 2012-2013 Clemens Niederberger +% Copyright 2012-2015 Clemens Niederberger % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -34,118 +34,65 @@ % If you have any ideas, questions, suggestions or bugs to report, please % feel free to contact me. % -------------------------------------------------------------------------- -% in order to compile this documentation you need the document class -% `cnpkgdoc' which you can get here: -% https://bitbucket.org/cgnieder/cnpkgdoc/ -% -\PassOptionsToPackage{supstfm=libertinesups}{superiors} -\documentclass{cnpkgdoc} -\docsetup{ - pkg = idxcmds , - subtitle = create commands for adding formatted index entries, - language = en , - code-box = { - backgroundcolor = gray!5!white , - skipbelow = .6\baselineskip plus .5ex minus .5ex , - skipabove = .6\baselineskip plus .5ex minus .5ex , - roundcorner = 3pt , +\documentclass[load-preamble,add-index,scrartcl={DIV10}]{cnltx-doc} +\usepackage[utf8]{inputenc} +\usepackage{idxcmds} +\setcnltx{ + package = {idxcmds} , + authors = Clemens Niederberger , + email = contact@mychemistry.eu , + url = http://www.mychemistry.eu/forums/forum/idxcmds/ , + abstract = {% + create commands for adding formatted index entries% } , - gobble = 1 -} - -\addcmds{acr,environ,file,hsnbg,KOMAScript,name,test} -\addcmds{ - @ifstar, - cmd,cmd@base,cmd@idx,cmd@nostar,cmd@star, - indexentry + add-cmds = { + newidxcmd,newsubidxcmd,newsubmainidxcmd + } , + add-silent-cmds = { + acr,environ,file,hsnbg,KOMAScript,scientist,test,@ifstar, + cmd,cmd@base,cmd@idx,cmd@nostar,cmd@star, + indexentry + } , + index-setup = { othercode=\footnotesize,noclearpage } , + makeindex-setup = { columns=3, columnsep=1em , intoc , title=Package Index } } +\usepackage{imakeidx} +\makeindex[name=environments,title=Index of Environments,intoc,columns=2] +\makeindex[name=\jobname-examples,title=Index of Examples,intoc,columns=3] -\cnpkgusecolorscheme{friendly} -\usepackage[oldstyle,proportional]{libertine} -\usepackage[libertine]{newtxmath} -\usepackage{libertinehologopatch} -\setmonofont[Scale=MatchLowercase]{Bitstream Vera Sans Mono} +\usepackage[ +backend=biber, +style=cnltx, +sortlocale=en_US, +indexing=cite, +useprefix]{biblatex} +\addbibresource{cnltx.bib} -\usepackage[english]{selnolig} +\defbibheading{bibliography}{\addsec{References}} +\usepackage{csquotes} -\renewcommand*\othersectionlevelsformat[3]{% - \textcolor{main}{#3\autodot}\enskip} -\renewcommand*\partformat{% - \textcolor{main}{\partname~\thepart\autodot}} -\usepackage{fnpct} -\pagestyle{headings} +\usepackage[biblatex]{embrac}[2012/06/29] +\ChangeEmph{[}[,.02em]{]}[.055em,-.08em] +\ChangeEmph{(}[-.01em,.04em]{)}[.04em,-.05em] -\usepackage{imakeidx} -\usepackage{filecontents} -\begin{filecontents*}{\jobname.ist} - heading_prefix "{\\bfseries " - heading_suffix "\\hfil}\\nopagebreak\n" - headings_flag 1 - delim_0 "\\dotfill\\hyperpage{" - delim_1 "\\dotfill\\hyperpage{" - delim_2 "\\dotfill\\hyperpage{" - delim_r "}\\textendash\\hyperpage{" - delim_t "}" - suffix_2p "\\nohyperpage{\\,f.}" - suffix_3p "\\nohyperpage{\\,ff.}" -\end{filecontents*} -\indexsetup{othercode=\footnotesize,noclearpage} -\makeindex[options={-s \jobname.ist},intoc,columns=3] -\makeindex[name=examples,title=Example Index,intoc,columns=3] - -\usepackage[backend=biber,style=alphabetic]{biblatex} -\addbibresource{\jobname.bib} -\begin{filecontents}{\jobname.bib} -@package{pkg:etoolbox, - title = {\paket*{etoolbox}}, - author = {Philipp Lehman}, - date = {2011-01-21}, - version = {2.1}, - url = {http://mirror.ctan.org/macros/latex/contrib/etoolbox} -} -@package{pkg:imakeidx, - title = {\paket*{imakeidx}}, - author = {Claudio Beccari and Enrico Gregorio}, - date = {2013-03-26}, - version = {1.3}, - url = {http://mirror.ctan.org/macros/latex/contrib/imakeidx} -} -@package{pkg:ltxcmds, - title = {\paket*{ltxcmds}}, - author = {Heiko Oberdiek}, - date = {2011-11-09}, - version = {1.22}, - url = {http://mirror.ctan.org/tex-archive/macros/latex/contrib/oberdiek/} -} -@package{pkg:pgfopts, - title = {\paket*{pgfopts}}, - author = {Joseph Wright}, - date = {2011-06-02}, - version = {2.1}, - url = {http://mirror.ctan.org/macros/latex/contrib/pgfopts} -} -\end{filecontents} +% \setidxcmds{idx-cmd=\index[\jobname-examples]} -\newidxcmd\acr{\textsc{#1}} -\newidxcmd[{\index[examples]}]\environ{\texttt{#1}}[ (Environment)] -\newidxcmd\name{\textsf{#1}} -\newsubmainidxcmd\file{\textsf{#1}} -\newsubidxcmd\test{Test}{\textcolor{red}{#1}} -\newsubidxcmd*\hsnbg{\name[Heisenberg]{Werner Heisenberg}}{#1} +\newidxcmd[{\index[\jobname-examples]}]\acr{\textsc{#1}} +\newidxcmd[{\index[environments]}]\environ{\texttt{#1}}[ (Environment)] +\newidxcmd[{\index[\jobname-examples]}]\scientist{\textsf{#1}} +\newsubmainidxcmd[{\index[\jobname-examples]}]\file{\textsf{#1}} +\newsubidxcmd[{\index[\jobname-examples]}]\test{Test}{\textcolor{red}{#1}} +\newsubidxcmd*[{\index[\jobname-examples]}]\hsnbg{\scientist[Heisenberg]{Werner Heisenberg}}{#1} \begin{document} -\section{Licence and Requirements}\label{sec:license}\secidx{Licence} -Permission is granted to copy, distribute and/or modify this software under -the terms of the \LaTeX{} Project Public License, version 1.3 or later -(\url{http://www.latex-project.org/lppl.txt}). The package has the status -``maintained.'' +\section{Licence and Requirements}\label{sec:license} +\license -\idxcmds loads and needs the the packages \paket{etoolbox}~\cite{pkg:etoolbox}, -\paket{pgfopts}~\cite{pkg:pgfopts} and \paket{ltxcmds}~\cite{pkg:ltxcmds}. -\secidx*{Licence} +\idxcmds\ loads and needs the the packages \pkg{etoolbox}~\cite{pkg:etoolbox}, +\pkg{pgfopts}~\cite{pkg:pgfopts} and \pkg{ltxcmds}~\cite{pkg:ltxcmds}. -\section{Motivation}\secidx{Motivation} +\section{Motivation} When working on a larger document and designing and writing the macros for various bits and pieces I was going to use I found myself repeatedly writing the same kind of macros again and again that had some kind of semantic @@ -153,221 +100,221 @@ meaning, maybe some markup definitions that also created an index entry and had a star form for omitting the index entry. They all had more or less the following structure: -\begin{beispiel}[code only] - \makeatletter - \newcommand*\cmd{\@ifstar\cmd@star\cmd@nostar} - \newcommand*\cmd@star[1]{\cmd@base{#1}} - \newcommand*\cmd@nostar[1]{\cmd@base{#1}\cmd@idx{#1}} - \newcommand*\cmd@base[1]{\textit{#1}} - \newcommand*\cmd@idx[1]{\index{#1@\cmd@base{#1}}} - \makeatother -\end{beispiel} +\begin{sourcecode} + \makeatletter + \newcommand*\cmd{\@ifstar\cmd@star\cmd@nostar} + \newcommand*\cmd@star[1]{\cmd@base{#1}} + \newcommand*\cmd@nostar[1]{\cmd@base{#1}\cmd@idx{#1}} + \newcommand*\cmd@base[1]{\textit{#1}} + \newcommand*\cmd@idx[1]{\index{#1@\cmd@base{#1}}} + \makeatother +\end{sourcecode} After having copied and pasted this code for the fourth time I thought: you -should have a command that does this for you. That was when \cmd{newidxcmd} +should have a command that does this for you. That was when \cs{newidxcmd} was born. This command soon enough got some extensions, \eg, giving the commands thus defined an optional argument that allowed specifying the sorting. It wasn't long before I realized that I might want to use this -\cmd{newidxcmd} again in other documents which was when I wrote the first +\cs{newidxcmd} again in other documents which was when I wrote the first draft of this package. -I added other commands, \cmd{newsubmainidxcmd} and \cmd{newsubidxcmd}, which I +I added other commands, \cs{newsubmainidxcmd} and \cs{newsubidxcmd}, which I didn't (and still don't) really use or need but of which I thought they could be useful for others, and here we are. -\secidx*{Motivation} - -\section{Usage}\label{sec:usage}\secidx{Usage} -\subsection{Available Commands}\secidx[Available Commands]{Usage} -\idxcmds provides these commands: -\begin{beschreibung} - \Befehl{newidxcmd}[]{\cmd*{cmd}}\ma{}\oa{}\newline - Defines a command \cmd*{cmd} that formats its argument according to - \code{} and creates an index entry with \code{} - that gets \code{} appended. Refer to the argument of \cmd*{cmd} - in \code{} with \code{\#1}. + +\section{Usage}\label{sec:usage} +\subsection{Available Commands} +\idxcmds\ provides these commands: +\begin{commands} + \command{newidxcmd}[\oarg{index cs}\marg{cs}\marg{formatting specs}\oarg{append}] + Defines a command \meta{cs} that formats its argument according to + \meta{formatting specs} and creates an index entry with \meta{index cs} + that gets \meta{append} appended. Refer to the argument of \meta{cs} + in \meta{formatting specs} with \code{\#1}. - Also defines a command \cmd*{cmdidx} that allows to only create an index - entry. See section~\ref{ssec:command:usage:newidxcmd} for examples and - further description of its functionality. Default for \code{} is - \cmd{index}. - \Befehl{newsubidxcmd}*[]{\cmd*{cmd}}\ma{
}\ma{}\oa{}\newline - Defines a command \cmd*{cmd} that formats its argument according to - \code{} and creates an index sub-entry to \code{
} with \code{} that gets \code{} - appended. Refer to the argument of \cmd*{cmd} in \code{} - with \code{\#1}. + Also defines a command \cs*{\meta{cs}idx} that allows to only create an + index entry. See section~\ref{sec:command:usage:newidxcmd} for examples + and further description of its functionality. Default for \meta{index cs} + is \cs{index}. + \command{newsubidxcmd}[\sarg\oarg{index cs}\marg{cs}\marg{main + entry}\marg{form. specs}\oarg{append}] + Defines a command \meta{cs} that formats its argument according to + \meta{form. specs} and creates an index sub-entry to \meta{main entry} + with \meta{index cs} that gets \meta{append} appended. Refer to the + argument of \meta{cs} in \code{form.\@ specs} with \code{\#1}. - Also defines a command \cmd*{cmdidx} that allows to only create an index - entry. See section~\ref{ssec:command:usage:newsubidxcmd} for further - description of its functionality. Default for \code{} is - \cmd{index}. - \Befehl{newsubmainidxcmd}[]{\cmd*{cmd}}\ma{}\oa{}\newline - Defines a command \cmd*{cmd} that formats its argument according to - \code{} and creates an index sub-entry to a main entry with - \code{} that gets \code{} appended. Refer to - the argument of \cmd*{cmd} in \code{} with \code{\#1}. + Also defines a command \cs*{\meta{cs}idx} that allows to only create an + index entry. See section~\ref{sec:command:usage:newsubidxcmd} for further + description of its functionality. Default for \meta{index cs} is + \cs*{index}. + \command{newsubmainidxcmd}[\oarg{index cs}\marg{cs}\marg{form. specs}\oarg{append}] + Defines a command \meta{cs} that formats its argument according to + \meta{form. specs} and creates an index sub-entry to a main entry with + \meta{index cs} that gets \meta{append} appended. Refer to the argument + of \meta{cs} in \meta{form. specs} with \code{\#1}. - Also defines a command \cmd*{cmdidx} that allows to only create an index - entry. The main entry is specified at use time. See - section~\ref{ssec:command:usage:newsubmainidxcmd} for examples and further - description of its functionality. Default for \code{} is - \cmd{index}. -\end{beschreibung} - -The commands \cmd*{cmd} defined this way are robust but their formatting + Also defines a command \cs*{\meta{cs}idx} that allows to only create an + index entry. The main entry is specified at use time. See + section~\ref{sec:command:usage:newsubmainidxcmd} for examples and further + description of its functionality. Default for \meta{index cs} is + \cs*{index}. +\end{commands} + +The commands \meta{cs} defined this way are robust but their formatting argument is not placed in a group. Keep this in mind when you use -\cmd*{bfseries} or something in a definition. \cmd*{cmd} will be defined -using \paket{etoolbox}' \cmd{newrobustcmd} which means an error will be thrown -if \cmd*{cmd} is already defined. +\cs*{bfseries} or something in a definition. \meta{cs} will be defined using +\pkg{etoolbox}' \cs*{newrobustcmd} which means an error will be thrown if +\meta{cs} is already defined. Of course these commands cannot cover all possible use cases for index entries but that is not the intention of this package, anyway. -\subsection{Command Usage}\label{ssec:command:usage}\secidx[Command Usage]{Usage} -\subsubsection{\cmd*{newidxcmd}}\label{ssec:command:usage:newidxcmd} -The command \cmd{newidxcmd}{\cmd*{cmd}}\ma{} will define a -new command \cmd*{cmd} with the following syntax: -\begin{beschreibung} - \Befehl{cmd}*{}\newline - format \code{} according to specifications, no index entry. - \Befehl{cmd}[]{}\oa{}\newline - format \code{} according to specifications, add formatted index - entry, sorted according to \code{} or, if the optional argument - is left out, sorted according to \code{}. \code{} is added to +\subsection{Command Usage}\label{sec:command:usage} +\subsubsection{\cs*{newidxcmd}}\label{sec:command:usage:newidxcmd} +The command \cs{newidxcmd}\Marg{\cs*{foo}}\marg{formatting specs} will define +a new command \cs*{foo} with the following syntax: +\begin{commands} + \command*{foo}[\sarg\marg{text}] + format \meta{text} according to specifications, no index entry. + \command*{foo}[\oarg{sort idx}\marg{text}\oarg{append}] + format \meta{text} according to specifications, add formatted index + entry, sorted according to \meta{sort idx} or, if the optional argument + is left out, sorted according to \meta{text}. \meta{append} is added to the index entry if the trailing optional argument is used (this can be useful for instance for getting formatted page numbers). - \Befehl{cmdidx}[]{}\oa{}\newline - add formatted index entry, sorted according to \code{} or, if the - optional argument is left out, sorted according to \code{}. - \code{} is added to the index entry if the trailing optional argument - is used. -\end{beschreibung} + \command*{fooidx}[\oarg{sort idx}\marg{text}\oarg{append}] + add formatted index entry, sorted according to \meta{sort idx} or, if the + optional argument is left out, sorted according to \meta{text}. + \meta{append} is added to the index entry if the trailing optional + argument is used. +\end{commands} Let's see an example: -\begin{beispiel} - % in the preamble, probably: - % \newidxcmd{\acr}{\textsc{#1}} - % \newidxcmd[{\index[examples]}]{\environ}{\texttt{#1}}[ (Environment)] - % \newidxcmd{\name}{\textsf{#1}} - \acr{cd}, \acr{id} +\begin{example} + % in the preamble, probably: + % \newidxcmd{\acr}{\textsc{#1}} + % \newidxcmd[{\index[environments]}]{\environ}{\texttt{#1}}[ (Environment)] + % \newidxcmd{\scientist}{\textsf{#1}} + \acr{cd}, \acr{id} + + \environ{center}, \environ{flushleft} + + \scientist*{Albert Einstein}, \scientist[Heisenberg]{Werner Heisenberg} +\end{example} +You will find these examples in the index of examples or the index of +environments, respectively. The second set of examples shows the purpose of +the first optional argument: if you have several indexes --~like this +documentation has for demonstration purposes~-- you might need to specify the +index command used\footnote{This document uses + \pkg{imakeidx}~\cite{pkg:imakeidx} for this purpose.}. If you want to prove +if the example worked: \scientist*{Albert Einstein} should not be found in the +index and \scientist*{Werner Heisenberg} should be sorted under +\emph{Heisenberg}. Both \environ*{center} and \environ*{flushleft} ahould be +found in the examples index. + +Now let's disect the example a bit. The uses of \cs*{acr}\Marg{cd}, +\cs*{scientist}\sarg\Marg{Albert Einstein} and \cs*{environ}\Marg{center} will +essentially expand to +\begin{sourcecode} + % \acr{cd} => + \textsc{cd}\index{cd@\textsc{cd}} + % and in \jobname.idx => + \indexentry{cd@\textsc {cd}}{3} - \environ{center}, \environ{flushleft} - - \name*{Albert Einstein}, \name[Heisenberg]{Werner Heisenberg} -\end{beispiel} -You will find these examples in the index or the examples index, -respectively. The second set of examples shows the purpose of the first -optional argument: if you have several indexes --~like this documentation has -for demonstration purposes~-- you might need to specify the index command -used\footnote{This document uses \paket*{imakeidx}~\cite{pkg:imakeidx} for - this purpose.}. If you want to prove if the example worked: \name*{Albert - Einstein} should not be found in the index and \name*{Werner Heisenberg} -should be sorted under \emph{Heisenberg}. Both \environ*{center} and -\environ*{flushleft} ahould be found in the examples index. - -Now let's disect the example a bit. The uses of \cmd*{acr}{cd}, -\cmd*{name}*{Albert Einstein} and \cmd*{environ}{center} will essentially -expand to -\begin{beispiel}[code only] - % \acr{cd} => - \textsc{cd}\index{cd@\textsc{cd}} - % and in \jobname.idx => - \indexentry{cd@\textsc {cd}}{3} - - % \name*{Albert Einstein} => - \textsf{Albert Einstein} - - % \environ{center} => - \texttt{center}\index[examples]{center@\texttt{center} (Environment)} - % and in examples.idx => - \indexentry{center@\texttt {center} (Environment)}{3} -\end{beispiel} - -\subsubsection{\cmd*{newsubidxcmd}}\label{ssec:command:usage:newsubidxcmd} -The command \cmd{newsubidxcmd}*{\cmd*{cmd}}\ma{
}\ma{} will define a new command \cmd*{cmd} with the same syntax as -\cmd{newidxcmd} does. However, \cmd{newsubidxcmd} has an additional argument + % \scientist*{Albert Einstein} => + \textsf{Albert Einstein} + + % \environ{center} => + \texttt{center}\index[environments]{center@\texttt{center} (Environment)} + % and in examples.idx => + \indexentry{center@\texttt {center} (Environment)}{3} +\end{sourcecode} + +\subsubsection{\cs*{newsubidxcmd}}\label{sec:command:usage:newsubidxcmd} +The command \cs{newsubidxcmd}\sarg\Marg{\cs*{foo}}\marg{main entry}\marg{form. + specs} will define a new command \cs*{foo} with the same syntax as +\cs{newidxcmd} does. However, \cs{newsubidxcmd} has an additional argument that specifies the main index entry this group of sub entries belongs to. For the unstarred variant this argument can be some arbitrary main entry. For the -starred variant it demands a command plus argument defined by \cmd{newidxcmd} +starred variant it demands a command plus argument defined by \cs{newidxcmd} as argument. -\begin{beispiel} - % preamble: - % \newsubidxcmd{\test}{Test}{\textcolor{red}{#1}} - % \newsubidxcmd*{\hsnbg}{\name[Heisenberg]{Werner Heisenberg}}{#1} - \name[Heisenberg]{Werner Heisenberg} was born in - \hsnbg[Wuerzburg]{W\"urzburg (Germany)}. He worked as a - professor in \hsnbg{Leipzig (Germany)}. And this is a - \test{test}. -\end{beispiel} - -\subsubsection{\cmd*{newsubmainidxcmd}}\label{ssec:command:usage:newsubmainidxcmd} -The command \cmd{newsubmainidxcmd}{\cmd*{cmd}}\ma{} will define -a new command \cmd*{cmd} similar to \cmd{newsubidxcmd} but where the main -index entry is specified for every use case in the running text. \cmd*{cmd} +\begin{example} + % preamble: + % \newsubidxcmd{\test}{Test}{\textcolor{red}{#1}} + % \newsubidxcmd*{\hsnbg}{\scientist[Heisenberg]{Werner Heisenberg}}{#1} + \scientist[Heisenberg]{Werner Heisenberg} was born in + \hsnbg[Wuerzburg]{W\"urzburg (Germany)}. He worked as a + professor in \hsnbg{Leipzig (Germany)}. And this is a + \test{test}. +\end{example} + +\subsubsection{\cs*{newsubmainidxcmd}}\label{sec:command:usage:newsubmainidxcmd} +The command \cs{newsubmainidxcmd}\Marg{\cs*{foo}}\marg{form. specs} will define +a new command \cs*{foo} similar to \cs{newsubidxcmd} but where the main +index entry is specified for every use case in the running text. \cs*{foo} will have the following syntax: -\begin{beschreibung} - \Befehl{cmd}*{}\newline - format \code{} according to specifications, no index entry. - \Befehl{cmd}[]{}\ma{
}\oa{}\newline - format \code{} according to specifications, add formatted index - sub-entry to the main index entry \code{
}, sorted according to - \code{} or, if the optional argument is left out, sorted - according to \code{}. \code{} is added to the index entry if +\begin{commands} + \command*{foo}[\sarg\marg{text}] + format \meta{text} according to specifications, no index entry. + \command*{foo}[\oarg{sort idx}\marg{text}\marg{main entry}\oarg{append}] + format \meta{text} according to specifications, add formatted index + sub-entry to the main index entry \meta{main entry}, sorted according to + \meta{sort idx} or, if the optional argument is left out, sorted + according to \meta{text}. \meta{append} is added to the index entry if the trailing optional argument is used (this can be useful for instance for getting formatted page numbers). - \Befehl{cmdidx}[]{}\ma{
}\oa{}\newline - add formatted index sub-entry to the main index entry \code{
}, - sorted according to \code{} or, if the optional argument is left - out, sorted according to \code{}. \code{} is added to the + \command*{fooidx}[\oarg{sort idx}\marg{text}\marg{main entry}\oarg{append}] + add formatted index sub-entry to the main index entry \meta{main entry}, + sorted according to \meta{sort idx} or, if the optional argument is left + out, sorted according to \meta{text}. \meta{append} is added to the index entry if the trailing optional argument is used. -\end{beschreibung} - -\begin{beispiel} - % in the preamble, probably: - % \newsubmainidxcmd{\file}{\textsf{#1}} - \file{article}{classes} is a standard \LaTeX{} class. - \file{scrartcl}{KOMA-Script@\KOMAScript} is part of the \KOMAScript{} bundle. - \file*{test} is a dummy. -\end{beispiel} - -\subsection{Options}\secidx[Options]{Usage} -\idxcmds has the following options -- either setable as package option or with -the setup command \cmd{setidxcmds}{} which takes a comma separated +\end{commands} + +\begin{example} + % in the preamble, probably: + % \newsubmainidxcmd{\file}{\textsf{#1}} + \file{article}{classes} is a standard \LaTeX{} class. + \file{scrartcl}{KOMA-Script@\KOMAScript} is part of the \KOMAScript{} bundle. + \file*{test} is a dummy. +\end{example} + +\subsection{Options} +\idxcmds\ has the following options -- either setable as package option or with +the setup command \cs{setidxcmds}\marg{options} which takes a comma separated list of options: -\begin{beschreibung} - \Option{sort-sep}{}\Default{@} +\begin{options} + \keyval{sort-sep}{symbol}\Default{@} set makeindex symbol to separate the index into sorting and typesetting part as specified in the index style file. - \Option{sub-sep}{}\Default{!} + \keyval{sub-sep}{symbol}\Default{!} set makeindex symbol to add a sub entry as specified in the index style file. - \Option{idx-cmd}{}\Default{\cmd*{index}} + \keyval{idx-cmd}{cs}\Default{\cs*{index}} \sinceversion{0.2b}The default indexing command that is used by \idxcmds. -\end{beschreibung} -\secidx*{Usage} +\end{options} + +% \end{document} \printbibliography -\section{Implementation}\secidx{Implementation} -In the following code the lines 1--32 have been omitted. They only repeat the -license statement which has already been mentioned in -section~\ref{sec:license}. +% \section{Implementation} +% In the following code the lines 1--32 have been omitted. They only repeat the +% license statement which has already been mentioned in +% section~\ref{sec:license}. -\implementation[linerange={33-1000},firstnumber=33] -\secidx*{Implementation} +% \implementation[linerange={33-1000},firstnumber=33] -% \begingroup -\indexprologue{\noindent - This index has some peculiar entries in addition to the ones you would - normally expect. But actually they are the corresponding entries to the - examples shown in section~\ref{sec:usage}.% -} -\printindex -% \def\clearpage{\vskip\baselineskip} -\clearpage -\printindex[examples] -% \endgroup + +\printindex[\jobname-examples] + +\printindex[environments] + +% \indexprologue{\noindent +% This index has some peculiar entries in addition to the ones you would +% normally expect. But actually they are the corresponding entries to the +% examples shown in section~\ref{sec:usage}.% +% } +% \printindex \end{document} diff --git a/Master/texmf-dist/tex/latex/idxcmds/idxcmds.sty b/Master/texmf-dist/tex/latex/idxcmds/idxcmds.sty index ff8f7907232..0edfb9df9fe 100644 --- a/Master/texmf-dist/tex/latex/idxcmds/idxcmds.sty +++ b/Master/texmf-dist/tex/latex/idxcmds/idxcmds.sty @@ -8,7 +8,7 @@ % Web: https://bitbucket.org/cgnieder/idxcmds/ % E-Mail: contact@mychemistry.eu % -------------------------------------------------------------------------- -% Copyright 2012-2013 Clemens Niederberger +% Copyright 2012-2015 Clemens Niederberger % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -30,17 +30,17 @@ % If you have any ideas, questions, suggestions or bugs to report, please % feel free to contact me. % -------------------------------------------------------------------------- -\def\@idxcmds@date{2013/08/31} -\def\@idxcmds@version{v0.2b} -\def\@idxcmds@description{create commands for adding formatted index entries} +\newcommand*\idxcmds@date{2015/08/13} +\newcommand*\idxcmds@version{v0.2c} +\newcommand*\idxcmds@description{create commands for adding formatted index entries} -\ProvidesPackage{idxcmds}[\@idxcmds@date\space \@idxcmds@version\space - \@idxcmds@description\space (CN)] +\ProvidesPackage{idxcmds}[\idxcmds@date\space \idxcmds@version\space + \idxcmds@description\space (CN)] \RequirePackage{etoolbox,pgfopts,ltxcmds} % -------------------------------------------------------------------------- % message handling: -\def\@idxcmds@create@message#1{% +\newcommand*\idxcmds@create@message[1]{% \ifstrequal{#1}{Error} {% \lowercase{\csdef{@idxcmds@#1}}##1##2{% @@ -49,22 +49,22 @@ \lowercase{\csdef{@idxcmds@#1}}##1{% \csuse{Package#1}{idxcmds}{##1}}% }} -\@idxcmds@create@message{Error} -\@idxcmds@create@message{Warning} -\@idxcmds@create@message{WarningNoLine} -\@idxcmds@create@message{Info} +\idxcmds@create@message{Error} +\idxcmds@create@message{Warning} +\idxcmds@create@message{WarningNoLine} +\idxcmds@create@message{Info} % -------------------------------------------------------------------------- % package options: -\def\@idxcmds@sortsep{@} -\def\@idxcmds@subsep{!} -\def\@idxcmds@default@index{\index} +\newcommand*\idxcmds@sortsep{@} +\newcommand*\idxcmds@subsep{!} +\newcommand*\idxcmds@default@index{\index} \pgfkeys{ idxcmds/.cd, - sort-sep/.code = \def\@idxcmds@sortsep{#1} , - sub-sep/.code = \def\@idxcmds@subsep{#1} , - idx-cmd/.code = \def\@idxcmds@default@index{#1} + sort-sep/.code = \def\idxcmds@sortsep{#1} , + sub-sep/.code = \def\idxcmds@subsep{#1} , + idx-cmd/.code = \def\idxcmds@default@index{#1} } \ProcessPgfOptions* @@ -72,19 +72,21 @@ % -------------------------------------------------------------------------- % a few helpers: -\def\@idxcmds@stripbs{\expandafter\@gobble\string} -\def\@idxcmds@csdef#1{\csdef{\@idxcmds@stripbs#1}} -\def\@idxcmds@csuse#1{\csuse{\@idxcmds@stripbs#1}} -\def\@idxcmds@appdef#1[#2]{\@idxcmds@csdef{#1@idx@app}{#2}} -\def\@idxcmds@newcommand{% +\newcommand*\idxcmds@stripbs{\expandafter\@gobble\string} +\newrobustcmd*\idxcmds@csdef[1]{\csdef{\idxcmds@stripbs#1}} +\newcommand*\idxcmds@csuse[1]{\csuse{\idxcmds@stripbs#1}} +\protected\def\idxcmds@appdef#1[#2]{\idxcmds@csdef{#1@idx@app}{#2}} +\newcommand*\idxcmds@newcommand{% \@ifstar - {\@idxcmds@newcommand@star} - {\@idxcmds@newcommand@nostar}% + {\idxcmds@newcommand@star} + {\idxcmds@newcommand@nostar}% +} +\newrobustcmd*\idxcmds@newcommand@nostar[1]{% + \expandafter\newrobustcmd\csname\idxcmds@stripbs#1\endcsname +} +\newrobustcmd*\idxcmds@newcommand@star[1]{% + \expandafter\newrobustcmd\expandafter*\csname\idxcmds@stripbs#1\endcsname } -\def\@idxcmds@newcommand@nostar#1{% - \expandafter\newrobustcmd\csname\@idxcmds@stripbs#1\endcsname} -\def\@idxcmds@newcommand@star#1{% - \expandafter\newrobustcmd\expandafter*\csname\@idxcmds@stripbs#1\endcsname} % -------------------------------------------------------------------------- % \newidxcmd[]{}{}[] @@ -94,184 +96,204 @@ % \cmd[]{} => alt. sort index % -\newrobustcmd\newidxcmd[3][\@idxcmds@default@index]{% - \@idxcmds@csdef{#2@base}##1{#3}% - \@idxcmds@csdef{#2@idx}##1##2##3{% +\newrobustcmd\newidxcmd[3][\idxcmds@default@index]{% + \idxcmds@csdef{#2@base}##1{#3}% + \idxcmds@csdef{#2@idx}##1##2##3{% \ifblank{##1} {% #1{% - ##2\@idxcmds@sortsep - \@idxcmds@csuse{#2@base}{##2}% - \@idxcmds@csuse{#2@idx@app}% + ##2\idxcmds@sortsep + \idxcmds@csuse{#2@base}{##2}% + \idxcmds@csuse{#2@idx@app}% ##3% }% } {% #1{% - ##1\@idxcmds@sortsep - \@idxcmds@csuse{#2@base}{##2}% - \@idxcmds@csuse{#2@idx@app}% + ##1\idxcmds@sortsep + \idxcmds@csuse{#2@base}{##2}% + \idxcmds@csuse{#2@idx@app}% ##3% }% }% }% - \@idxcmds@csdef{#2@star}##1{\@idxcmds@csuse{#2@base}{##1}}% - \@idxcmds@csdef{#2@nostar}{% - \ltx@ifnextchar[% - {\@idxcmds@csuse{#2@nostar@opt}} - {\@idxcmds@csuse{#2@nostar@opt}[]}}% - \@idxcmds@csdef{#2@nostar@opt}[##1]##2{% - \@idxcmds@csuse{#2@base}{##2}% - \ltx@ifnextchar@nospace[% - {\@idxcmds@csuse{#2@idx@optarg}{##1}{##2}} - {\@idxcmds@csuse{#2@idx}{##1}{##2}{}}}% - \@idxcmds@csdef{#2@idx@optarg}##1##2[##3]{% - \@idxcmds@csuse{#2@idx}{##1}{##2}{##3}}% + \idxcmds@csdef{#2@star}##1{\idxcmds@csuse{#2@base}{##1}}% + \idxcmds@csdef{#2@nostar}{% + \ltx@ifnextchar[% ] + {\idxcmds@csuse{#2@nostar@opt}} + {\idxcmds@csuse{#2@nostar@opt}[]}% + }% + \idxcmds@csdef{#2@nostar@opt}[##1]##2{% + \idxcmds@csuse{#2@base}{##2}% + \ltx@ifnextchar@nospace[% ] + {\idxcmds@csuse{#2@idx@optarg}{##1}{##2}} + {\idxcmds@csuse{#2@idx}{##1}{##2}{}}% + }% + \idxcmds@csdef{#2@idx@optarg}##1##2[##3]{% + \idxcmds@csuse{#2@idx}{##1}{##2}{##3}% + }% \newrobustcmd*#2{% \@ifstar - {\@idxcmds@csuse{#2@star}} - {\@idxcmds@csuse{#2@nostar}}}% - \@idxcmds@newcommand*{#2idx}[2][]{% - \ltx@ifnextchar@nospace[ - {\@idxcmds@csuse{#2@idx@optarg}{##1}{##2}} - {\@idxcmds@csuse{#2@idx}{##1}{##2}{}}}% - \ltx@ifnextchar[% - {\@idxcmds@appdef{#2}} - {\@idxcmds@appdef{#2}[]}% + {\idxcmds@csuse{#2@star}} + {\idxcmds@csuse{#2@nostar}}% + }% + \idxcmds@newcommand*{#2idx}[2][]{% + \ltx@ifnextchar@nospace[% ] + {\idxcmds@csuse{#2@idx@optarg}{##1}{##2}} + {\idxcmds@csuse{#2@idx}{##1}{##2}{}}% + }% + \ltx@ifnextchar[% ] + {\idxcmds@appdef{#2}} + {\idxcmds@appdef{#2}[]}% } % --------------------------------------------------------------------------- % \newsubmainidxcmd[]{}{}[] -\newrobustcmd\newsubmainidxcmd[3][\@idxcmds@default@index]{% - \@idxcmds@csdef{#2@base}##1{#3}% - \@idxcmds@csdef{#2@idx}##1##2##3##4{% +\newrobustcmd\newsubmainidxcmd[3][\idxcmds@default@index]{% + \idxcmds@csdef{#2@base}##1{#3}% + \idxcmds@csdef{#2@idx}##1##2##3##4{% \ifblank{##1} {% #1{% - ##3\@idxcmds@subsep##2\@idxcmds@sortsep - \@idxcmds@csuse{#2@base}{##2}% - \@idxcmds@csuse{#2@idx@app}% + ##3\idxcmds@subsep##2\idxcmds@sortsep + \idxcmds@csuse{#2@base}{##2}% + \idxcmds@csuse{#2@idx@app}% ##4% }% }{% #1{% - ##3\@idxcmds@subsep##1\@idxcmds@sortsep - \@idxcmds@csuse{#2@base}{##2}% - \@idxcmds@csuse{#2@idx@app}% + ##3\idxcmds@subsep##1\idxcmds@sortsep + \idxcmds@csuse{#2@base}{##2}% + \idxcmds@csuse{#2@idx@app}% ##4% }% }% }% - \@idxcmds@csdef{#2@star}##1{\@idxcmds@csuse{#2@base}{##1}}% - \@idxcmds@csdef{#2@nostar}{% - \ltx@ifnextchar[% - {\@idxcmds@csuse{#2@nostar@opt}} - {\@idxcmds@csuse{#2@nostar@opt}[]}}% - \@idxcmds@csdef{#2@nostar@opt}[##1]##2##3{% - \@idxcmds@csuse{#2@base}{##2}% - \ltx@ifnextchar@nospace[% - {\@idxcmds@csuse{#2@idx@optarg}{##1}{##2}{##3}} - {\@idxcmds@csuse{#2@idx}{##1}{##2}{##3}{}}}% - \@idxcmds@csdef{#2@idx@optarg}##1##2##3[##4]{% - \@idxcmds@csuse{#2@idx}{##1}{##2}{##3}{##4}}% + \idxcmds@csdef{#2@star}##1{\idxcmds@csuse{#2@base}{##1}}% + \idxcmds@csdef{#2@nostar}{% + \ltx@ifnextchar[% ] + {\idxcmds@csuse{#2@nostar@opt}} + {\idxcmds@csuse{#2@nostar@opt}[]}% + }% + \idxcmds@csdef{#2@nostar@opt}[##1]##2##3{% + \idxcmds@csuse{#2@base}{##2}% + \ltx@ifnextchar@nospace[% ] + {\idxcmds@csuse{#2@idx@optarg}{##1}{##2}{##3}} + {\idxcmds@csuse{#2@idx}{##1}{##2}{##3}{}}% + }% + \idxcmds@csdef{#2@idx@optarg}##1##2##3[##4]{% + \idxcmds@csuse{#2@idx}{##1}{##2}{##3}{##4}% + }% \newrobustcmd*#2{% \@ifstar - {\@idxcmds@csuse{#2@star}} - {\@idxcmds@csuse{#2@nostar}}}% - \@idxcmds@newcommand*{#2idx}[3][]{% - \@idxcmds@csuse{#2@idx}{##1}{##2}{##3}}% - \ltx@ifnextchar[% - {\@idxcmds@appdef{#2}} - {\@idxcmds@appdef{#2}[]}% + {\idxcmds@csuse{#2@star}} + {\idxcmds@csuse{#2@nostar}}% + }% + \idxcmds@newcommand*{#2idx}[3][]{% + \idxcmds@csuse{#2@idx}{##1}{##2}{##3}% + }% + \ltx@ifnextchar[% ] + {\idxcmds@appdef{#2}} + {\idxcmds@appdef{#2}[]}% } % --------------------------------------------------------------------------- % \newsubidxcmd[]{}{}{}[] % \newsubidxcmd*[]{}{
}{}[] -\newif\if@idxcmds@sub@star +\newbool{idxcmds@sub@star} % get main if starred -\def\@idxcmds@extract@main#1#2{% - \ltx@ifnextchar[% - {\@idxcmds@extract@main@aux{#1}{#2}} - {\@idxcmds@extract@main@aux{#1}{#2}[]}} -\def\@idxcmds@extract@main@aux#1#2[#3]#4{% - \@idxcmds@csdef{#1@main}{\@idxcmds@csuse{#2@base}{#4}}% +\newrobustcmd*\idxcmds@extract@main[2]{% + \ltx@ifnextchar[% ] + {\idxcmds@extract@main@aux{#1}{#2}} + {\idxcmds@extract@main@aux{#1}{#2}[]}% +} +\protected\def\idxcmds@extract@main@aux#1#2[#3]#4{% + \idxcmds@csdef{#1@main}{\idxcmds@csuse{#2@base}{#4}}% \ifstrempty{#3} - {\@idxcmds@csdef{#1@main@sort}{#4}} - {\@idxcmds@csdef{#1@main@sort}{#3}}} + {\idxcmds@csdef{#1@main@sort}{#4}} + {\idxcmds@csdef{#1@main@sort}{#3}}% +} \newcommand*\newsubidxcmd{% \@ifstar - {\@idxcmds@sub@startrue\@idxcmds@subidx} - {\@idxcmds@sub@starfalse\@idxcmds@subidx}} -\newrobustcmd\@idxcmds@subidx[4][\@idxcmds@default@index]{% - \@idxcmds@csdef{#2@base}##1{#4}% - \if@idxcmds@sub@star - \@idxcmds@extract@main#2#3% - \@idxcmds@csdef{#2@idx}##1##2##3{% + {\booltrue{idxcmds@sub@star}\idxcmds@subidx} + {\boolfalse{idxcmds@sub@star}\idxcmds@subidx}% +} +\newrobustcmd\idxcmds@subidx[4][\idxcmds@default@index]{% + \idxcmds@csdef{#2@base}##1{#4}% + \ifbool{idxcmds@sub@star}{% + \idxcmds@extract@main#2#3% + \idxcmds@csdef{#2@idx}##1##2##3{% \ifblank{##1} {% #1{% - \@idxcmds@csuse{#2@main@sort}\@idxcmds@sortsep - \@idxcmds@csuse{#2@main}% - \@idxcmds@subsep##2\@idxcmds@sortsep - \@idxcmds@csuse{#2@base}{##2}% - \@idxcmds@csuse{#2@idx@app}% + \idxcmds@csuse{#2@main@sort}\idxcmds@sortsep + \idxcmds@csuse{#2@main}% + \idxcmds@subsep##2\idxcmds@sortsep + \idxcmds@csuse{#2@base}{##2}% + \idxcmds@csuse{#2@idx@app}% ##3% }% }{% #1{% - \@idxcmds@csuse{#2@main@sort}\@idxcmds@sortsep - \@idxcmds@csuse{#2@main}% - \@idxcmds@subsep##1\@idxcmds@sortsep - \@idxcmds@csuse{#2@base}{##2}% - \@idxcmds@csuse{#2@idx@app}% + \idxcmds@csuse{#2@main@sort}\idxcmds@sortsep + \idxcmds@csuse{#2@main}% + \idxcmds@subsep##1\idxcmds@sortsep + \idxcmds@csuse{#2@base}{##2}% + \idxcmds@csuse{#2@idx@app}% ##3% }% - }}% - \else - \@idxcmds@csdef{#2@idx}##1##2##3{% + }% + }% + }{% + \idxcmds@csdef{#2@idx}##1##2##3{% \ifblank{##1} {% #1{% #3% - \@idxcmds@subsep##2\@idxcmds@sortsep - \@idxcmds@csuse{#2@base}{##2}% - \@idxcmds@csuse{#2@idx@app}% + \idxcmds@subsep##2\idxcmds@sortsep + \idxcmds@csuse{#2@base}{##2}% + \idxcmds@csuse{#2@idx@app}% ##3% }% }{% #1{% #3% - \@idxcmds@subsep##1\@idxcmds@sortsep - \@idxcmds@csuse{#2@base}{##2}% - \@idxcmds@csuse{#2@idx@app}% + \idxcmds@subsep##1\idxcmds@sortsep + \idxcmds@csuse{#2@base}{##2}% + \idxcmds@csuse{#2@idx@app}% ##3% }% - }}% - \fi - \@idxcmds@csdef{#2@star}##1{\@idxcmds@csuse{#2@base}{##1}}% - \@idxcmds@csdef{#2@nostar}{% - \ltx@ifnextchar[% - {\@idxcmds@csuse{#2@nostar@opt}} - {\@idxcmds@csuse{#2@nostar@opt}[]}}% - \@idxcmds@csdef{#2@nostar@opt}[##1]##2{% - \@idxcmds@csuse{#2@base}{##2}% - \ltx@ifnextchar@nospace[% - {\@idxcmds@csuse{#2@idx@optarg}{##1}{##2}} - {\@idxcmds@csuse{#2@idx}{##1}{##2}{}}}% - \@idxcmds@csdef{#2@idx@optarg}##1##2[##3]{% - \@idxcmds@csuse{#2@idx}{##1}{##2}{##3}}% + }% + }% + }% + \idxcmds@csdef{#2@star}##1{\idxcmds@csuse{#2@base}{##1}}% + \idxcmds@csdef{#2@nostar}{% + \ltx@ifnextchar[% ] + {\idxcmds@csuse{#2@nostar@opt}} + {\idxcmds@csuse{#2@nostar@opt}[]}% + }% + \idxcmds@csdef{#2@nostar@opt}[##1]##2{% + \idxcmds@csuse{#2@base}{##2}% + \ltx@ifnextchar@nospace[% ] + {\idxcmds@csuse{#2@idx@optarg}{##1}{##2}} + {\idxcmds@csuse{#2@idx}{##1}{##2}{}}% + }% + \idxcmds@csdef{#2@idx@optarg}##1##2[##3]{% + \idxcmds@csuse{#2@idx}{##1}{##2}{##3}% + }% \newrobustcmd*#2{% \@ifstar - {\@idxcmds@csuse{#2@star}} - {\@idxcmds@csuse{#2@nostar}}}% - \@idxcmds@newcommand*{#2idx}[2][]{% - \@idxcmds@csuse{#2@idx}{##1}{##2}}% - \ltx@ifnextchar[% - {\@idxcmds@appdef{#2}} - {\@idxcmds@appdef{#2}[]}% + {\idxcmds@csuse{#2@star}} + {\idxcmds@csuse{#2@nostar}}% + }% + \idxcmds@newcommand*{#2idx}[2][]{% + \idxcmds@csuse{#2@idx}{##1}{##2}% + }% + \ltx@ifnextchar[% ] + {\idxcmds@appdef{#2}} + {\idxcmds@appdef{#2}[]}% } \endinput @@ -283,4 +305,4 @@ that allows appending stuff to the index entry at use-time 2013/05/14 v0.2a - added \setidxcmds 2013/08/31 v0.2b - added option `idx-cmd' - +2015/08/13 v0.2c - removed spurious space, minor code changes -- cgit v1.2.3