1

I am writing a document related to computer science and I want to include a short summary of the commands that appear through the text at the end. I am using the listing package to handle the code and I want to use the nomencl package to create the summary, but when I try to add a new entry inside the lstinline environment, it does not appear in the nomenclature:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{nomencl}
\usepackage{listings}
\makenomenclature

\begin{document}

\section{section}

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. \clearpage \mbox{}

\nomenclature{\lstinline|test command|}{This is a test with a command} \nomenclature{test}{This is a test without a command}

\printnomenclature \end{document}

The code produces the following output:

document without the nomenclature entry

As you can see the nomenclature entry inside lstinline does not appear. Is there a way of making this work or can you think of an alternative?

videbar
  • 11

1 Answers1

1

For \nomenclature the | and ! characters are reserved. You can use for example \lstlinline?test?. For the rest this question is a near-duplicate of Using \lstinline inside a \item and the solution is also from there.

MWE:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{nomencl}
\usepackage{listings}
\makenomenclature

\begin{document} \lstset{language=bash} \section{section}

Lorem ipsum dolor sit amet, consectetuer adipiscing elit.

\nomenclature{\lstinline?echo?}{This is a test with a command} \nomenclature{test}{This is a test without a command}

\makeatletter \let\orig@item\item

\def\item{% @ifnextchar{[}% {\lstinline@item}% {\orig@item}% }

\begingroup \catcode\]=\active \gdef\lstinline@item[{% \setbox0\hbox\bgroup \catcode]=\active \let]\lstinline@item@end } \endgroup

\def\lstinline@item@end{% \egroup \orig@item[\usebox0]% }

\makeatother

\printnomenclature

\end{document}

Result:

enter image description here

Marijn
  • 37,699