3

Simple question: I'm using ieeetran for a very long document that I'm preparing an index for using makeidx. Index entries that include subitems are not indented as expected. I presume this is because ieeetran has their own styling for subsections, but I don't know how to change it just for the index. My MWE:

\documentclass[journal]{ieeetran}
\usepackage{makeidx} \makeindex

\begin{document}

This is a keyword\index{keywords}. But this one is a subkeyword.\index{keywords!subkeyword}  
\index{anotherkeyword!andsubentry}

\section{Index}
\printindex 

\end{document}

This produces the following result. Notice how the subentries are not indented. Any ideas on easy ways to fix this? Answers are much appreciated. Thank you!

enter image description here

1
  • The class doesn't define a theindex environment.
    – egreg
    Dec 5, 2014 at 18:21

1 Answer 1

2

The IEEEtran class (by the way, it's better using this name and not ieeetran that works only under Windows) doesn't provide a theindex environment.

Here's a modified definition taken from the one in article.cls that, however, omits the page break. The commented lines in the code are from the original version, the two added one are marked as such.

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

\documentclass[journal]{IEEEtran}
\usepackage{makeidx} \makeindex

\makeatletter
\newenvironment{theindex}
 {%
%  \if@twocolumn
%  \@restonecolfalse
%  \else
%  \@restonecoltrue
%  \fi
%  \twocolumn[\section*{\indexname}]%
%  \@mkboth{\MakeUppercase\indexname}%
%          {\MakeUppercase\indexname}%
%  \thispagestyle{plain}%
  % no page break, continue the columns<-- added
  \section{\indexname}% <----------------- added
  \parindent\z@
  \parskip\z@ \@plus .3\p@\relax
%  \columnseprule \z@
%   \columnsep 35\p@
  \let\item\@idxitem
 }
 {%
%  \if@restonecol\onecolumn\else\clearpage\fi
 }
\newcommand\@idxitem{\par\hangindent 40\p@}
\newcommand\subitem{\@idxitem \hspace*{20\p@}}
\newcommand\subsubitem{\@idxitem \hspace*{30\p@}}
\newcommand\indexspace{\par \vskip 10\p@ \@plus5\p@ \@minus3\p@\relax}
\makeatother

\begin{document}

This is a keyword\index{keywords}. But this one is a subkeyword.\index{keywords!subkeyword}  
\index{anotherkeyword!andsubentry}

\printindex 

\end{document}

enter image description here

0

You must log in to answer this question.

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