[Tex/LaTex] nomencl package and vertical bar |

nomenclature

I am using the nomencl package; however, it seems that my nomenclature entries which contain a vertical bar | in math mode are not handled properly. Is this a known issue, and is there a suggested workaround?

As an example, the following entry in my document

\nomenclature{$s(A)$}{equivalent to $|A|$}

makes it into the .nlo file, but not the .nls file.

Best Answer

The nomencl package uses the standard MakeIndex process and | is a special character for the \index command. So there's no way unless you produce a variant of nomencl.ist that disables that special character:

%% ---- for input file ----
keyword    "\\nomenclatureentry"
%% Germans might want to change this and delete the two %%
%% quote '"'
%% ---- for output file ----
preamble   "\\begin{thenomenclature} \n"%
postamble  "\n\n\\end{thenomenclature}\n" group_skip "\n"
delim_0    ""
delim_1    ""
delim_2    ""
%% The next lines will produce some warnings when
%% running Makeindex as they try to cover two different
%% versions of the program:
lethead_prefix "\n \\nomgroup{"
lethead_suffix "}\n"
lethead_flag   1
heading_prefix "\n \\nomgroup{"
heading_suffix "}\n"
headings_flag  1
encap '?'

The last line is the additional one, I've put a question mark that probably you won't use in a nomenclature entry. Save the file as mynomencl.ist and use

makeindex ⟨filename ⟩.nlo -s mynomencl.ist -o ⟨filename ⟩.nls

to produce the .nls file.

It's probably better to remember \vert instead of |. By the way, the amsmath package provides \lvert and \rvert that should be preferred to simple bars: \lvert A\rvert will have correct spacing also in critical situations when |A| might not.

For the rare usage of |, you can also get around the issue with

\nomenclature{$s(A)$}{equivalent to $"|A"|$}
Related Question