[texhax] symbols list with makeindex

Heiko Oberdiek heiko.oberdiek at googlemail.com
Wed Apr 28 18:04:44 CEST 2010


Hi Barbara,

2010/4/28 Barbara Beeton <bnb at ams.org>:
> we have a book that includes a small
> list of symbols.  they have been written
> out to an .idx file for processing by
> makeindex.  there are no entries citing
> more than one page number.
>
> rather than sorting them into "alphabetical"
> order, is it possible with makeindex to
> generate a .ind file in page number order?

Yes, example:
\documentclass{book}
\usepackage{makeidx}
\makeindex

\usepackage{zref-abspage}

\makeatletter
\newcommand*{\SymbolIndex}{%
 \@bsphack
 \begingroup
 \@sanitize
 \@SymbolIndex
}
\def\@SymbolIndex#1{%
 \let\TheSymbolNumberPage\relax
 \@wrindex{%
   \@SymbolChar
   \TheSymbolNumberPage
   \@QuoteChar#1%
   \@ActualChar
   \@QuoteChar
   \@backslashchar verb9\@QuoteChar#19%
 }%
}
\newcommand*{\TheSymbolNumberPage}{%
 \ifnum\value{abspage}<100 0\fi
 \ifnum\value{abspage}<1000 0\fi
 \ifnum\value{abspage}<10000 0\fi
 \ifnum\value{abspage}<100000 0\fi
 \ifnum\value{abspage}<1000000 0\fi
 \ifnum\value{abspage}<10000000 0\fi
 \the\value{abspage}%
}

\def\@ActualChar{@}
\def\@QuoteChar{"}
\def\@SymbolChar{$}
\makeatother

\begin{document}
\frontmatter
\chapter{Introduction}

\index{hello}
\SymbolIndex{,}
\SymbolIndex{$}
Hello World

\mainmatter
\chapter{Main chapter}
X\SymbolIndex{@}
\SymbolIndex{:}
\SymbolIndex{[}
\chapter{Next chapter}
\SymbolIndex{\}
\SymbolIndex{#}
\SymbolIndex{!}

\printindex
\end{document}

Yours sincerely
  Heiko Oberdiek


More information about the texhax mailing list