# Generate only the index, no main body text

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]

\begin{document}
Test\index{foo}
Testing\index{bar}
}%

\printindex
\end{document}

• Index writing is performed at \shipout time, so if nothing is shipped out no index is produced. Dec 19 '12 at 22:02
• why not just have a new document which inputs the .ind file of the first (and does nothing else) 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. Dec 19 '12 at 22:14
• look in chat:-) 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"? Dec 19 '12 at 22:36

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.

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