在命名法中使用时应小心的特殊字符

在命名法中使用时应小心的特殊字符

我在 LaTeX 的命名法中很难写出 |.|。它适用于命名法中的第一个项目,但不适用于以下第二个项目:

\documentclass[10pt,journal]{IEEEtran}
\usepackage{nomencl}
\usepackage{ifthen}
\renewcommand{\nomgroup}[1]{%
    \ifthenelse{\equal{#1}{C}}{\item[\textbf{Constants}]}{%
        \ifthenelse{\equal{#1}{V}}{\item[\textbf{Variables}]}{%
            \ifthenelse{\equal{#1}{K}}{\item[\textbf{Symbols}]}{%
            \ifthenelse{\equal{#1}{S}}{\item[\textbf{sets}]}{}}}}
}
\makenomenclature

\begin{document}
\nomenclature[Km]{$\leftarrow\cdot\rightarrow$}{Number of element in a set.} %
\nomenclature[Km]{$\left|\cdot \right|$}{Number of element in a set.} %
Say something.
\printnomenclature

\end{document}

有人能帮助我吗,为什么它没有显示出来?

答案1

搜索了一下并找到了以下解决方案:

\documentclass[10pt,journal]{IEEEtran}
\usepackage{nomencl}
\usepackage{amsmath} % <=== don't forget
\usepackage{ifthen}
\renewcommand{\nomgroup}[1]{%
    \ifthenelse{\equal{#1}{C}}{\item[\textbf{Constants}]}{%
        \ifthenelse{\equal{#1}{V}}{\item[\textbf{Variables}]}{%
            \ifthenelse{\equal{#1}{K}}{\item[\textbf{Symbols}]}{%
            \ifthenelse{\equal{#1}{S}}{\item[\textbf{sets}]}{}}}}
}
\makenomenclature

\begin{document}
\nomenclature[Km]{$\leftarrow\cdot\rightarrow$}{Number of element in a set.} %
\nomenclature[Km]{$ \left\lvert \cdot \right\rvert $}{Number of element in a set.} %
%% based on the comment from @NicolaTalbot and the answer from @egreg in https://tex.stackexchange.com/questions/324639/adding-exists-to-the-nomenclature
\nomenclature[Km]{$ \left"| \cdot \right"| $}{Number of element in a set.} %
Say something.
\printnomenclature

\end{document}

相关内容