4

While trying to view my document in Lyx I kept getting an error while compiling the document:

LaTex Error: Lonely\item--perhaps a missing list environment

The descriptions stated:

\item [{BER}]
               \begingroup Bit Error Rate\nomeqref {42}\nompageref{16}
Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.

By using the note feature (commenting out) on each of the nomenclature entries I found that I'd tried to define a nomenclature within a subsection title.

Commenting out the nomenclature entry allowed the document to compile and I could see my list.

karlkoeller
  • 124,410

2 Answers2

4

You can safely define a nomenclature entry inside a sectioning command. You just have to protect fragile commands like \nomrefpage and \nomrefeq.

For example, you can write

\section{Bit Error Rate (BER)\nomenclature{BER}{Bit Error Rate\protect\nomrefpage}}

or

\subsection{Meaning of $x$\nomenclature{$x$}{Unknown variable\protect\nomrefeq}}

and they work fine.

Also, be sure to use \nomrefpage and \nomrefeq instead of \nompageref and \nomeqref (the latter are commands used inside the .nls file to indicate the same things...).

MWE

\documentclass{article}

\usepackage{nomencl}

\makenomenclature

\begin{document}

\printnomenclature

\bigskip

\section{Bit Error Rate (BER)\nomenclature{BER}{Bit Error Rate\protect\nomrefpage}}

\begin{equation}
\textup{BER}=x
\end{equation}

\subsection{Meaning of $x$\nomenclature{$x$}{Unknown variable\protect\nomrefeq}}

$x$ is an unknown variable

\end{document} 

Output:

enter image description here

karlkoeller
  • 124,410
3

You must use the optional argument to \section and \subsection:

% arara: pdflatex
% arara: nomencl
% arara: pdflatex

\documentclass{article}

\usepackage{nomencl}

\makenomenclature

\begin{document}

\tableofcontents

\printnomenclature

\bigskip

\section
[Bit Error Rate (BER)]
{Bit Error Rate (BER)\nomenclature{BER}{Bit Error Rate\nomrefpage}}

\begin{equation}
\textup{BER}=x
\end{equation}

\subsection
[Meaning of $x$]
{Meaning of $x$\nomenclature{$x$}{Unknown variable\nomrefeq}}

$x$ is an unknown variable

\end{document} 

Why did I say “must”? Because if you just \protect the fragile commands in the titles, you'll get an entry also for the appearance in the table of contents (and probably distinct from the one in the title).

However, I can't recommend adding nomenclature references in titles; it's better to have them in text.

egreg
  • 1,121,712