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?

1 Answer 1

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.

You must log in to answer this question.

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