5

I need to index the string $@

\documentclass[a4paper,10pt,openany]{scrbook}

\usepackage{imakeidx}
\makeindex

\newcommand{\indexthing}[1]%
{%
    \index{#1@\texttt{#1} (thing)}%
    \index{things!\texttt{#1}}%
}

\begin{document}

\chapter{ch1}

foo\index{foo}
bar\index{bar}
\index{\$\@}      % PROBLEM A
\indexthing{\$\@} % PROBLEM B

\chapter{ch2}

baz\index{baz}

\printindex

\end{document}

If you comment out the PROBLEM B line the document compiles but $ appears in the index instead of $@.

If you leave the PROBLEM B line in, it won't compile at all

! Extra }, or forgotten \endgroup.
l.17     \subitem m {}}
                       , 1

How do I include @ in an index?

4

You can use the quote character to prefix the actual character:

\documentclass[a4paper,10pt,openany]{scrbook}

\usepackage{imakeidx}
\makeindex

\newcommand{\indexthing}[1]%
{%
    \index{#1@\texttt{#1} (thing)}%
    \index{things!\texttt{#1}}%
}

\begin{document}

\chapter{ch1}

foo\index{foo}
bar\index{bar}
\index{\$"@}      % PROBLEM A
\indexthing{\$"@} % PROBLEM B

\chapter{ch2}

baz\index{baz}

\printindex

\end{document}

The characters depend on the MakeIndex style. For more information see, e.g., section INPUT STYLE SPECIFIERS in the MakeIndex manual.

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.