7

I would like to discard the entire document and have only the index remaining.

Note:

My naive attempt below does not produce any output. I want Page 2 of the document that gets generated if the \usebox{\DiscardBox} line is un-commented, but not Page 1.

Code:

\documentclass{article}
\usepackage{imakeidx}
\usepackage{hyperref}

\makeindex[columns=1]

\newsavebox{\DiscardBox}

\begin{document}
  \savebox{\DiscardBox}{%
    Test\index{foo}
    Testing\index{bar}
  }%
  %\usebox{\DiscardBox}

  \printindex
\end{document}
  • Index writing is performed at \shipout time, so if nothing is shipped out no index is produced. – egreg Dec 19 '12 at 22:02
  • 2
    why not just have a new document which inputs the .ind file of the first (and does nothing else) – David Carlisle Dec 19 '12 at 22:06
  • @DavidCarlisle: WOW!! That is pure genius... Never occurred to me. Seems to work fine. What do I need to do get only a one column index? Using just \input{<file>.ind} produces a two column output. – Peter Grill Dec 19 '12 at 22:14
  • look in chat:-) – David Carlisle Dec 19 '12 at 22:14
  • Are you talking visually remove everything but the index? That is, if you have a document of 10 pages with 1 page dedicated to the index, then you can delete pages 1-9 and only be left with "page 10"? – Werner Dec 19 '12 at 22:36
5

imakeidx sets the number of columns with \imki@columns; so you can simply build another document with the following format:

\documentclass{article}
\usepackage{imakeidx}
\usepackage{hyperref}

\begin{document}
\makeatletter
\def\imki@columns{1}
\def\indexname{External index}
\makeatother
\input{mainfile.ind}

\end{document}

leaving to the class the rest.

6

Just have a new document which inputs the .ind file of the first (and does nothing else) .

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.