• No results found

“\keyindex{Einstein},” which produces “Einstein” in the text and an index entry under “Einstein, Albert”. Of course, the correct index entries must be col- lected somewhere.

N/A
N/A
Protected

Academic year: 2021

Share "“\keyindex{Einstein},” which produces “Einstein” in the text and an index entry under “Einstein, Albert”. Of course, the correct index entries must be col- lected somewhere."

Copied!
3
0
0

Bezig met laden.... (Bekijk nu de volledige tekst)

Hele tekst

(1)

The keyindex package

Richard Zach

1 Introduction

The keyindex package provides functionality for producing an index with- out directly entering index entries into the text using the \index command, but instead by looking up short keys and printing a predefined string in the main text and adding a corresponding index entry. The standard use case is the production of an index of names: Rather than having to write in the text, e.g., “Einstein\index{Einstein, Albert}” every time, write

“\keyindex{Einstein},” which produces “Einstein” in the text and an index entry under “Einstein, Albert”. Of course, the correct index entries must be col- lected somewhere.

The package distribution also includes a bash script makenameindex which produces a key index file for use with keyindex from a text file with entries of the form

hlast namei, hfirst namei hkeyi|hlast namei, hfirst namei hkeyi@hindexentryi

2 Interactions

keyindex requires the ifthen package.

3 Usage

\keyindex[hindex optioni]{hkey i} prints the text associated with index key

\keyindex

hkeyi (using the hooks \keyindexformat and \missingkeyindexformat) fol- lowed by an index entry for hkeyi. The index entry is generated using the hook

\keyindexcommand and the optional argument hindex optioni is added to the ar- gument of \keyindexcommand after a |. For instance, \keyindex[(]{Einstein}

might produce the same as

Einstein\index{Einstein, Albert|(}.

\keyindexprint{hkey i} prints only the text corresponding to hkey i, but doesn’t

\keyindexprint

\keyindexonly

This document corresponds to keyindex 1.0, dated 2019/04/05.

1

(2)

add anything to the index. \keyindexonly{hkeyi}[hindex optioni] only adds the index entry but doesn’t print anything in the text.

\keyindexfile{hfilei} will load the index key definitions from hfilei.kix,

\keyindexfile

which is assumed to contain only a list of lines of the form

\keyindexentry {hkey i}{hprint text i}{hindex text i}

If it is not called, keyindex will use \jobname.kix as default. This must be used in the preamble.

These are hooks to carry out the formatting in the text of the text corre-

\keyindexformat

\missingkeyindexformat

\keyindexcommand

sponding to an index entry, or adding the entry to the index. They can be re- defined using \renewcommand. By default, \keyindexformat{htext i} just adds htext i to the document, \missingkeyindexformat{htexti} adds \textbf{htexti}, and \keyindexcommand{htext i} issues \index{htext i}.

4 Implementation

4.1 Setup

1 \RequirePackage{ifthen}

\keyindexfile sets \@keyindexfile to its argument; we set \@keyindexfile to default to \jobname.kix

2 \newcommand*{\keyindexfile}[1]{%

3 \renewcommand*{\@keyindexfile}{#1}}

4 \newcommand*{\@keyindexfile}{\jobname.kix}

\keyindexformat formats index text; default: just prints argument.

5 \newcommand*{\keyindexformat}[1]{#1}

\missingkeyindexformat prints index key when not defined; by default, \textbf.

6 \newcommand*{\missingkeyindexformat}[1]{%

7 \textbf{#1}}

\keyindexcommand{hindex text i} adds {hindex text i} to the index; by default, it does \index{hindex text i} but can be redefined.

8 \newcommand*{\keyindexcommand}[1]{\index{#1}}

At the beginning of the document, we read the index key definition file

9 \AtBeginDocument{%

10 \InputIfFileExists{\@keyindexfile}{%

11 \PackageInfo{keyindex}{Using index key definition file

12 \@keyindexfile.}}{%

13 \PackageWarning{keyindex}{No index key definition file

14 \@keyindexfile!}}}

\keyindex[hindex optioni]{hkey i} prints text for key hkey i, and indexes it (with

|hindex optioni, if present). Printing is done by \keyindexprint, indexing by

\keyindexonly. If the key is undefined, we issue a warning and print the key (using \missingkeyindexformat), not its replacement text.

15 \newcommand*{\keyindexprint}[1]{\@ifundefined{kix@e@\detokenize{#1}}{%

16 \PackageWarning{keyindex}{Index key \detokenize{#1}

2

(3)

17 undefined}%

18 \missingkeyindexformat{#1}}{%

19 \keyindexformat{\@nameuse{kix@e@\detokenize{#1}}}}}

20 \newcommand*{\keyindexonly}[2][]{\@ifundefined{kix@e@\detokenize{#2}}{%

21 \PackageWarning{keyindex}{Index key \detokenize{#2}

22 undefined}}{%

23 \ifthenelse{\equal{#1}{}}{%

24 \keyindexcommand{\@nameuse{kix@i@\detokenize{#2}}}}{%

25 \keyindexcommand{\@nameuse{kix@i@\detokenize{#2}}|#1}}}}

26 \newcommand{\keyindex}[2][]{\keyindexprint{#2}\keyindexonly[#1]{#2}}

The file \@keyindexfile must contain lines of the form \keyindexentry{hkeyi}{htext i}{hindex entryi}. It is read at the beginning of the document and for each key, defines com-

mands \kix@e@hkeyi and \kix@i@hkeyi which evaluate to htext i and hindex entryi, respectively. Duplicate definitions are ignored but generate a warning.

27 \newcommand*{\keyindexentry}[3]{%

28 \@ifundefined{kix@e@\detokenize{#1}}{%

29 \@namedef{kix@e@\detokenize{#1}}{#2}%

30 \@namedef{kix@i@\detokenize{#1}}{#3}}{%

31 \PackageWarning{keyindex}{Duplicate definition for keyindex key

32 \detokenize{#1} ignored}}}

3

Referenties

GERELATEERDE DOCUMENTEN

This article presents an index that includes this information, a Real Estate Market Index (“REMI”) that combines median sales price, volume (number of sales) and median days on

Compared with the highly cited publications indicator, a scoring rule that uses a concave function to determine the score of a publication has the advantage that the

De dagelijkse stijging in voeropname werd ook niet beïnvloed door de opname van voer tijdens de zoogperiode. In de analyse van de dagelijkse stijging van de voeropname zijn de

Spearman’s correlation using bootstrap for the h-index and alt-index of source titles from Altmetric.com and Scopus.. Correlation is significant at the 0.01

format htexti according to specifications, add formatted index sub-entry to the main index entry hmain entryi, sorted according to hsort idxi or, if the optional argument is left

• Instead of using \SkipIndex\AltDuBois many times, we create a cross- reference in the preamble so that no page entry for the alternate form will occur in the

(The text occurring in the document is also typeset within the argument of \tstidxtext.. The default value is to use a dark grey, but since the default values for the predefined.

Durham and London: Duke University Press, 2001, pp.. “Earl, Saint, Bishop, Skald –