我需要索引字符串$@
\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}
如果注释掉 PROBLEM B 行,文档可以编译,但$
会出现在索引中而不是$@
。
如果你保留 PROBLEM B 行,它根本无法编译
! Extra }, or forgotten \endgroup.
l.17 \subitem m {}}
, 1
如何将其纳入@
索引?
答案1
您可以使用引用字符作为前缀实际的特点:
\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}
字符取决于 MakeIndex 样式。有关更多信息,请参见第节输入样式说明符在 MakeIndex 手册中。