[texhax] running makeindex from a tex file (by shell scape)

Heiko Oberdiek heiko.oberdiek at googlemail.com
Sun Jan 23 17:29:29 CET 2011


On Mon, Jan 24, 2011 at 01:41:30AM +1100, Vafa Khalighi wrote:

> Can you please tel me why this does not work with pdflatex --shell-escape
> test
> 
>  \documentclass{minimal}
> 
> \usepackage{makeidx}
> 
> \makeindex
> 
> \makeatletter
> 
> \renewcommand\printindex{%
> 
> \immediate\closeout\@indexfile
> 
> \immediate\write18{makeindex \jobname.idx}
> 
> \input{\jobname.ind}}
> 
> \makeatother
> 
> \begin{document}
> 
> This is a test.
> 
> \index{Test}\index{Exam}

\index needs the page number, therefore the write is delayed until
the page is shipped out.

> \printindex

The page with the \index commands isn't shipped out yet, but you
are already closing the .idx file. Therefore put a \newpage
at the beginning of \printindex.

Yours sincerely
  Heiko Oberdiek


More information about the texhax mailing list