0

I want to have my index (using imakeidx) at the beginning of my document, so for that I need to use the nonewpage option. I also want to right-align the page numbers in the index with dots in-between, so I created the .ist file

delim_0 "\\dotfill"

However, the nonewpage option prevents the .ist file from running properly. For example:

\documentclass{article}
\usepackage[nonewpage]{imakeidx} % taking out nonewpage lets the ist file put dots in    
\makeindex[options=-s debugging]

\begin{document}
Some text
\index{refer}
\index{Howsit}
\printindex
\end{document}

Can I achieve both an index at the front of the document, as well as having dots leading up to right-aligned page numbers?

8
  • If you use nonewpage you have to run makeindex manually.
    – egreg
    Sep 11, 2017 at 20:43
  • @egreg I'm using pdfLaTeX+MakeIndex+BibTeX to compile the MWE. Taking out nonewpage puts the dots in without running the makeindex separately.
    – ahorn
    Sep 11, 2017 at 20:48
  • That's clear. You need to run makeindex -s debugging <filename> in the second step: when you run makeindex manually it knows nothing about the options given to \makeindex.
    – egreg
    Sep 11, 2017 at 20:49
  • @egreg I don't know what you mean. Do you mean putting makeindex -s debugging on the second line of the .ist file? I also named the .tex file debugging.
    – ahorn
    Sep 11, 2017 at 21:02
  • No, the -s debugging bit should go on the command line you call makeindex with.
    – egreg
    Sep 11, 2017 at 21:05

1 Answer 1

2

With the option nonewpage it's impossible for imakeidx to call automatically makeindex, because the index file has to be closed before the last page is shipped out and entries in it would be lost.

Assuming your file is named ahorn.tex, you have to run

pdflatex ahorn
makeindex -s debugging ahorn
pdflatex ahorn

(maybe with other calls in between, for instance bibtex). How you pass the option to makeindex depends on how you do the run and the front-end you use.

If you are able to run Arara (see How to use arara with TeXworks), you can do

% arara: pdflatex
% arara: makeindex: { style: debugging }
% arara: pdflatex

\documentclass{article}
\usepackage[nonewpage]{imakeidx} % taking out nonewpage lets the ist file put dots in
\makeindex

\begin{document}
Some text
\index{refer}
\index{Howsit}
\printindex
\end{document}

and the single call

arara ahorn

will take care of everything.

enter image description here

1
  • I haven't yet used arara, but I've now used the command prompt in this way for the first time.
    – ahorn
    Sep 11, 2017 at 21:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .