4

I studied the documentation but was not clever enough to understand how to automatically index multiple kinds of keywords. I give a MWE below. When I run the document, only class [1] keywords appear in the index; class [2] does not.

\documentclass{book}
\usepackage{makeidx}\makeindex 
\usepackage{listings}
\begin{document}
\lstset{
classoffset=0,
morekeywords=[1]{
    False   },
morekeywords=[2]{
    AssertionError  },
index=[1][keywords],
index=[2][keywords],
}
\lstinline!False! makes an index entry, but
\lstinline!AssertionError! does not.
\printindex
\end{document}
3

The number in the first optional argument of index does not refer to the class number of the keywords, but to the class number of the index. This allows to setup different indexes. The class number for the keywords are appended to the name except for the first class: keywords, keywords2, keywords3, ...

The following works:

\documentclass{book}
\usepackage{makeidx}\makeindex
\usepackage{listings}
\begin{document}
\lstset{
  classoffset=0,
  morekeywords=[1]{
    False          
  },
  morekeywords=[2]{        
    AssertionError
  },
  index=[1][keywords],
  moreindex=[1][keywords2],
}
\lstinline!False! makes an index entry, but
\lstinline!AssertionError! does not.
\printindex
\end{document}

Index

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.