Debian Codegraph @

texmf-dist/doc/latex/keyindex/makenameindex

raw
1 if [ -z $1 ]; then
2 echo usage: makenameindex infile
3 echo
4 echo Produces a file infile.kix, suitable for importing in the preamble of
5 echo a LaTeX file, which provides the command \name\<key\>. Usually, \<key\>
6 echo will be a last name, and \name\<key\> will insert the last name in the
7 echo text as well as an index entry of the form last name, first name. The
8 echo file is generated from infile.txt, which contains lines of the form
9 echo
10 echo last name, first name
11 echo key\|last name, first name
12 echo key@indexentry
13 echo
14 echo key\|last name, first name is used to disambiguate people with the same
15 echo last name. key@indexentry is used to typeset \<key\> in the text
16 echo but index indexentry, e.g., Euklid@Euclid.
17 else
18 echo makenameindex $1.txt, writing to $1.kix
19 for key in `grep -o '^[^|@,]*' $1.txt` ; do
20 if [ `grep -c "^$key[|@,]" $1.txt` -gt 1 ]; then
21 echo "Key $key defined more than once!"
22 fi
23 done
24 echo "% $1.kix" > $1.kix
25 echo "% Generated from $1.txt on `date`" >> $1.kix
26 grep '|' $1.txt | sed 's/^\([^|]*\)|\([^,]*\), *\(.*\)/\\keyindexentry{\1}{\2}{\2, \3}/' >>$1.kix
27 grep '@' $1.txt | grep -v '@.*@' | sed 's/^\([^@]*\)@\(.*\)/\\keyindexentry{\1}{\1}{\2}/' >>$1.kix
28 grep '@' $1.txt | grep '@.*@' | sed 's/^\([^@]*\)@\([^@]*\)@\(.*\)/\\keyindexentry{\1}{\2}{\3}/' >>$1.kix
29 grep -v '[|@]' $1.txt | sed 's/^\([^,]*\), *\(.*\)/\\keyindexentry{\1}{\1}{\1, \2}/' >>$1.kix
30 sort -o $1.kix $1.kix
31 fi