4

I'm using the package imakeidx in order to generate the indexes for my document, but i get an issue when i use the option noclearpage being that the index is not printed (or it don't print all entries - incomplete index).

I use this option to avoid the index in the next page \clearpage.

Problem

With

\indexsetup{level=\section,toclevel=section}

works perfect! but the index pass to the next page, and with

\indexsetup{level=\section,toclevel=section,noclearpage}

the index is not printed.

MWE

\documentclass{article}
\usepackage{imakeidx}
\indexsetup{level=\section,toclevel=section,noclearpage} %
\makeindex
\begin{document}
\tableofcontents
\section{F}
a\index{first}
b\index{second}
\section{G}
c\index{third} d\index{four}
\printindex
\end{document}

I don't understand what is the problem?

Edit

I tried to add the nonewpage option suggested in the first answer, but the problem worsens because not even the .idx file is generated inclusive after of run repeatedly with pdflatex (Neither pdflatex --enable-write18 nor pdflatex -shell-escape work) generating a .log like (part)

...

No file indexsetupproblem.ind.

Package imakeidx Warning: Remember to run (pdf)latex again after calling
(imakeidx)                `makeindex indexsetupproblem.idx'.

[1

{C:/ProgramData/MiKTeX/2.9/pdftex/config/pdftex.map}
\indexentry{first}{1}
\indexentry{second}{1}
\indexentry{third}{1}
\indexentry{four}{1}
]

...

It seems that to add the nonewpage option inhibits definitely the creation of the .idx file (the file is created but empty).

  • I fear, this is not the right command here. The noclearpage is meant for multiple indices. You have to prevent the page break before writing \printindex! – LaRiFaRi Sep 2 '14 at 7:06
  • Related: tex.stackexchange.com/q/61089 – LaRiFaRi Sep 3 '14 at 6:17
5

Updated:

As my previous answer did not work, I asked Enrico Gregorio (the author and maintainer of imakeidx) for help. As he told me, this solution needs a fix of the package, if the option splitindex is not loaded. You find this fix in between \makeatletter\makeatother. Thanks to egreg. I mark this CW.


nonewpage inhibits the new page command to be issued when using an article type document class and multiple indices are being typeset. We don’t see why someone would use multiple indices in an article (except possibly for package documentations, which usually provide a macro index and a list of changes). (egreg 2013, imakeidx documentation)

% arara: pdflatex
% arara: makeindex
% arara: pdflatex
% arara: pdflatex

\documentclass{article}
\usepackage[nonewpage]{imakeidx}
\indexsetup{level=\section,toclevel=section} %
\makeindex
\makeatletter
\xpatchcmd{\imki@putindex}
{\immediate}
{\ifimki@disableautomatic\else\immediate}
{}{}
\xpatchcmd{\imki@putindex}
{\endcsname}
{\endcsname\fi}
{}{}
\makeatother
\begin{document}
    \tableofcontents
    \section{F}
    a\index{first}
    b\index{second}
    \section{G}
    c\index{third} d\index{four}
    \printindex
\end{document}
  • Sorry, but if i add the nonewpage option the .idx file isn't generated (it stays empty). – skpblack Sep 2 '14 at 23:08
  • @skpblack Now it works. – LaRiFaRi Sep 3 '14 at 7:43
  • It works, but disables the automatic way. – skpblack Sep 4 '14 at 3:50
  • @skpblack which automatic way? – LaRiFaRi Sep 5 '14 at 5:48
  • I must run makeindex manually – skpblack Sep 5 '14 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.