% \NeedsTeXFormat{LaTeX2e} % \ProvidesPackage{terms} % % \RequirePackage{makeidx} % \makeindex % % Package "term" for short declaration of terms in a text, which then can be collected % more easily in an index or may be emphasized in the running text. % % Author: Thomas Eckert, eckert(@)mathematik.uni-marburg.de % % Wishlist: % 1. Automatize the "!"-syntax of the \index command in package makeidx to get a subentry % only for multiple subs, but a simple comma separation for single subs. % 2. What about the idea in version 2 of saving the index entry for a term that it can % be reused by \term? Also labeling for complicated expressions? % 3. Perhaps automatically apply "+/*"-syntax for composed expressions (multiple words or % at least words with "-" inside? Which order then? % 4. A package option to disable the index. % 5. English glossary? % 6. A ";"-syntax for additional entries. % 7. Also a ":"-syntax instead of the optional-brackets. % 8. A new version with a "+*/"-syntax for the three possible combinations of "+,*". % % Version 3: Introduced "+/*" syntax in entries for short declaration of terms. % % % % Provided commands % % % \newcommand\Term[2][\relax]{\t@rm[#1]{#2}{main}} % \newcommand\term[2][\relax]{\t@rm[#1]{#2}{side}} % % Use as \Term[entry]{text} with optional argument set to if omitted. % % Then, a "*" in as "A*B" leads to an index entry \index{B!A} for not-empty A. % % And one can produce one additional entry by a "+" sign anywhere in A xor B. % % For example "+Vektor-*Bündel" will be found under "Bündel!Vektor-" and "Vektor-Bündel". % % % \newcommand\English[1]{ (englisch \textit{#1})}% To note an English expression for the term. % % % \let\textmain\textit% In \t@rm{text}{entry}{#3} the formatting of the term in the text is done % \let\textside\textit% via \csname text#3\endcsname resulting in \textmain for #3 as "main". % % % \let\main\textbf% Parameter #3 of \t@rm is directly transferred to \index{...|#3} for % \let\side\textrm% formatting of the page numbers. Confirm the makeindex package. % \def\see#1#2{\textit{#1}} % % % % % % Implementation % % % \newcommand\t@rm[3][\relax]{% % \ifx\relax#1\splitTerm{#2}\else\splitTerm{#1}\fi% Find "+/*"-entries. % \if\relax\MajorB% Create a major index entry (optional marked by "*" sign) % \index{\MajorA|#3}% % \else% % \index{\MajorA!\MajorB|#3}% % \fi% % \if\relax\MinorA\else% Create an optional minor index entry (marked by "+" sign) % \if\relax\MinorB% % \index{\MinorA|#3}% % \else% % \index{\MinorA!\MinorB @\textit{\MinorB}|#3}% % \fi% % \fi% % \csname text#3\endcsname{\expandafter\DelPlus@\DelStar@#2**°++Â*}% % % Produce the text, formatted and cleared of all signs "+/*". % } % % Technical macros to find entries for a Term % \newcommand\splitTerm[1]{% % \gdef\MajorA{\expandafter\Maj@rA\DelPlus@#1++Â**\relax*~}% % \gdef\MajorB{\expandafter\Maj@rB\DelPlus@#1++Â**\relax*~}% % \gdef\MinorA{\expandafter\Min@rA\DelStar@#1**°+\relax+~}% % \gdef\MinorB{\expandafter\Min@rB\DelStar@#1**°+\relax+~}% % } % \edef\DelPlus@#1+#2+#3Â*{#1#2}% #3 is only junk, but that's the trick: % \edef\DelStar@#1*#2*#3°{#1#2}% use as \DelStar@#1**°, where #1 is some stuff % \def\Maj@rA#1*#2*#3~{\if\relax#2#1\else#2\fi} % \def\Maj@rB#1*#2*#3~{\if\relax#2\else#1\fi} % \def\Min@rA#1+#2+#3~{\if\relax#2\else#2\fi} % \def\Min@rB#1+#2+#3~{\if\relax#2\else#1\fi} % Version 2 (trial): In \Term safe the entry text that it can be referred to by \term. % Problem: The Umlaute can't be used in \csname. No idea of some workaround. % Compare amsref package and (la)tex's (?) "do"-lists used there (extensive documentation). % % \newcommand\Term[2][\relax]{#2% % \ifx#1\or\relax% % \expandafter\ifx\csname T@rminus#2\endcsname\relax% % \index{#1}% % \else% % \index{\csname T@rminus#2\endcsname}% % \fi% % \else\index{#1}\fi% % } % Version 1: First use of "+"-symbol in the entry "syntax" % % \newcommand\Term[2][\relax]{% % % Use as \Term[entry]{text} with optional argument set to if omitted. % % Then a "+" in as "A+B" leads to an additional call \index{B!A}. % % For example "Lorentz-+Metrik" will be found under "Lorentz-Metrik" and "Metrik!Lorentz-". % \ifx#1\relax% % \splitTerm#2++*% The ++* is to get proper syntax for the \splitTerm in any case. % \def\TermText{\TermA\TermB}% Deleted any "+". % \else% % \def\TermText{#2}% #2 is already clean % \splitTerm#1++*% as before, but now with #1 % \fi% % \emph{\TermText}% Produce the emphasized text. % \index{\TermA\TermB|Main}% Create a (main) index entry. % \ifx\TermB{}\else % \index{\TermB!\TermA|see{\TermA\TermB}}% Second as marked by "+". % \fi% % } % % Technical macro to find additional entries for a term % \def\splitTerm#1+#2+#3*{% Argument #3 only collects the unused remains. % \xdef\TermA{#1}% % \xdef\TermB{#2}% % } % \endinput