add options to vocab class for providing index or not. give index an internal name and provide \printvocabindex command
This commit is contained in:
parent
adc5da4b6b
commit
b77f9a3299
1 changed files with 34 additions and 14 deletions
|
@ -3,22 +3,42 @@
|
||||||
%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%
|
||||||
%%Provides a \vocab<[name in index]>{vocabulary} command to print vocabulary in bold blue and automatically index it.
|
%%Provides a \vocab<[name in index]>{vocabulary} command to print vocabulary in bold blue and automatically index it.
|
||||||
|
|
||||||
\newif\ifenglish\englishtrue
|
\newif\ifmkessler@vocab@english\mkessler@vocab@englishtrue
|
||||||
\DeclareOption{german}{\englishfalse}
|
\DeclareOption{german}{\mkessler@vocab@englishfalse}
|
||||||
\DeclareOption{english}{\englishtrue}
|
\DeclareOption{english}{\mkessler@vocab@englishtrue}
|
||||||
|
|
||||||
|
\newif\ifmkessler@vocab@index\mkessler@vocab@indexfalse
|
||||||
|
\DeclareOption{index}{\mkessler@vocab@indextrue}
|
||||||
|
\DeclareOption{noindex}{\mkessler@vocab@indexfalse}
|
||||||
|
|
||||||
\DeclareOption*{\PackageWarning{mkessler-vocab}{Unknown '\CurrentOption'}}
|
\DeclareOption*{\PackageWarning{mkessler-vocab}{Unknown '\CurrentOption'}}
|
||||||
\ProcessOptions\relax
|
\ProcessOptions\relax
|
||||||
|
|
||||||
%%%%Management of vocabulary and corresponding index
|
%%%%Management of vocabulary and corresponding index
|
||||||
\RequirePackage{imakeidx}
|
|
||||||
\makeindex[columns=2, title=\ifenglish Index\else Stichwortverzeichnis\fi, intoc]
|
|
||||||
|
|
||||||
%Emphasize \vocabulary
|
|
||||||
\RequirePackage{xparse}
|
\RequirePackage{xparse}
|
||||||
\RequirePackage{expl3}
|
\RequirePackage{xcolor}
|
||||||
\ExplSyntaxOn
|
\ifmkessler@vocab@index
|
||||||
\NewDocumentCommand{\vocab}{O{} m}{
|
\RequirePackage{imakeidx}
|
||||||
|
\makeindex[name=mkessler@vocab@indexname, columns=2, title=\ifmkessler@vocab@english Index\else Stichwortverzeichnis\fi, intoc]
|
||||||
|
|
||||||
|
%Emphasize \vocabulary
|
||||||
|
\RequirePackage{expl3}
|
||||||
|
\ExplSyntaxOn
|
||||||
|
\NewDocumentCommand{\vocab}{O{} m}{
|
||||||
|
\textbf{\color{blue} #2}%
|
||||||
|
\if\relax\detokenize{#1}\relax%
|
||||||
|
\index[mkessler@vocab@indexname]{\text_titlecase_first:n{#2}} % true branch: #1 was empty
|
||||||
|
\else
|
||||||
|
\index[mkessler@vocab@indexname]{#1} % false branch: #1 was supplied
|
||||||
|
\fi
|
||||||
|
}
|
||||||
|
\ExplSyntaxOff
|
||||||
|
\newcommand\printvocabindex{
|
||||||
|
\printindex[mkessler@vocab@indexname]
|
||||||
|
}
|
||||||
|
\else
|
||||||
|
\NewDocumentCommand{\vocab}{O{} m }{
|
||||||
\textbf{\color{blue} #2}
|
\textbf{\color{blue} #2}
|
||||||
\ifthenelse{\isempty{#1}}{\index{\text_titlecase_first:n{#2}}}{\index{#1}}
|
}
|
||||||
}
|
\fi
|
||||||
\ExplSyntaxOff
|
|
||||||
|
|
Loading…
Reference in a new issue