summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/idxcmds
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/idxcmds')
-rw-r--r--Master/texmf-dist/tex/latex/idxcmds/idxcmds.sty308
1 files changed, 165 insertions, 143 deletions
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[<index cmd>]{<cs>}{<formatting specs>}[<app to idx entry>]
@@ -94,184 +96,204 @@
% \cmd[<sort idx>]{<text>} => 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[<index cmd>]{<cs>}{<formatting specs>}[<app to idx entry>]
-\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[<index cmd>]{<cs>}{<idx cmd>}{<formatting specs>}[<app to idx entry>]
% \newsubidxcmd*[<index cmd>]{<cs>}{<main entry>}{<formatting specs>}[<app to idx entry>]
-\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