[texhax] Indexing macros on TeXbook

Rodolfo Medina rodolfo.medina at gmail.com
Mon Aug 1 15:43:28 CEST 2016

I'm having a look at the indexing macros from the TeXbook on p.262 and trying
to apply them in pratice.  They seem to work.  What I want to do now is adding
vertical space before a new letter begins, but don't know how.  Here's my
test.tex file:

  \parindent=1em \maxdepth=\maxdimen
  \def\par{\endgraf \futurelet\next\inxentry}
  \obeylines \everypar={\hangindent 2\parindent}
  \exhyphenpenalty=10000 \raggedright}
\def\inxentry{\ifx\next\sub \let\next=\subentry
  \else\ifx\next\endindex \let\next=\vfill
  \else\let\next=\mainentry \fi\fi \next}
\let\sub=\indent \newtoks\maintoks \newtoks\subtoks

  \ifx\next\empty % do nothing if \botmark is null
  \else\noindent #1\continued %
    \ifx\next\empty % nothing more if \botmark has no \sub
    \else\let\sub=\continued \indent #2\fi
    \advance\dimen0 by-\prevdepth \kern\dimen0 \fi}
\def\continued{ ({\it continued}\thinspace):\endgraf}

Some text on p.1
\immediate\write\index{\noexpand\beginindex first entry,
\immediate\write\index{\noexpand\beginindex second entry,
  \openin \testin index.ind
    \closein \testin % file didn't exist
    \read\testin to \temp
      \closein \testin % file empty
      \closein \testin
             \input index.ind }


After processing it with simply `tex test', I execute the following small shell
script to sort entries:


cat index.idx | sort > index.ind

and then process test.tex once again.

Please help whoever can, thanks in advance.


More information about the texhax mailing list