The following steps will lead to a glossary and an acronym list in LyX. When using this approach, "nomenclature" and "nomenclature entries" in LyX cannot be used.
Setup
In the LaTeX Preamble ("Document > Setting...") we add:
\usepackage[acronym]{glossaries}
\makeglossaries
The generating the index files for the glossaries
package uses different options than for the nomencl
package. The following wrapper script needs to be used. saved in the home directory .
for linux, save the file as mkgloss.sh
in your home directory and make the script executable by chmod u+x mkgloss.sh
#!/bin/sh
makeglossaries `basename "$1" .glo`
for windows, (caution: not tested!) save the file as mkgloss.bat
in your home directory
REM for loop used for formatting purpose only
FOR /F %%I in ("%1") do makeglossaries %%~nI
We tell LyX to use this script instead of the default makeindex -s nomencl.ist
by changing the field "Nomenclature command" in "Tools > Preferences... > Output > LaTeX". We use the filename with absolute path. Depending on where you have saved the file, for example, for linux,
"/home/tux/mkgloss.sh"
or for windows,
"C:\Documents and Settings\Peter\mkgloss.bat"
Usage
Now, we can write acroyms and a glossary entries in the LyX document by using TeX code/ERT (Ctrl-L). For example,
\newglossaryentry{api}{type=\acronymtype, name={API}, description={Application
Programming Interface}, first={Application Programming Interface (API)},
see=[Glossary:]{apig}}
\newglossaryentry{apig}{name={API},
description={An Application Programming Interface (API) is a particular set
of rules and specifications that a software program can follow to access and
make use of the services and resources provided by another particular software
program that implements that API}}
In the LyX document \gls{api}
as TeX code/ERT will use the glossary entry api
and \glsadd{apig}
will add the entry apig
to the glossary without generating text.
Finally, we write the two pieces of TeX code \printglossary[type=\acronymtype]
and \printglossary[type=main]
at the end of the document (or whereever the acronym list and glossary should appear). Now the PDF displays both.
A working example can be found here (on that site save the text as ".lyx" file). Removing all page breaks from the example we get:
Notice: You can debug whether "mkgloss" script is correctly executed by opening LyX Messages Pane (View > Messages Pane). If the script is executed, you will see the script name appears somewhere in Messages Pane.
Problem: A change of an acronym entry seems to be missed by LyX and the acronym list in the output (PDF) is not updated.
Workaround: Add following TeX code/ERT in your LyX document:
\newglossaryentry{dummy}{name={DUMMY},
description={Type or erase a letter here and LyX will update the glossary and
acronym list (do *not* use space as only working under certain circumstances)}}
\glsadd{dummy}
By changing the description of this entry LyX will get reminded to update glossary and acronym list.
You're probably missing the necessary makeindex run (related question here). The following MWE using your excerpts works fine for me -- I recommend using latexmk and an appropriate .latexmkrc to make this easier:
\documentclass{report}
\usepackage[intoc]{nomencl}
\renewcommand{\nomname}{\large \textbf{Mathematical Notation}}
\makenomenclature
\usepackage{filecontents}
\begin{filecontents*}{test.csv}
Acronym,Description
LED,Light emitting diode
FET,Field effect transistor
\end{filecontents*}
\begin{filecontents*}{acronyms.tex}
\chapter*{Terminology / Notation}
\section*{\large \textbf{Acronyms / Abbreviations}}
\begin{itemize}
\DTLforeach*{acronyms}{\thisAcronym=Acronym,\thisDesc=Description}%
{\item \textbf{\thisAcronym} \thisDesc}%
\end{itemize}
\printnomenclature
\end{filecontents*}
\usepackage{datatool}
\DTLloaddb{acronyms}{test.csv}
\DTLsort{Acronym}{acronyms}
\begin{document}
\chapter{One}
This document works fine as long as you run the right \verb|makeindex| command.
It may be easiest to use \verb|latexmk| with the following lines in a file named
\verb|.latexmkrc| or \verb|latexmkrc| in the same directory as the .tex files.
\begin{verbatim}
add_cus_dep("nlo", "nls", 0, "nlo2nls");
sub nlo2nls {
system("makeindex $_[0].nlo -s nomencl.ist -o $_[0].nls -t $_[0].nlg");
}
\end{verbatim}
$\gamma = \int_1^\infty\left({1\over\lfloor x\rfloor}
-{1\over x}\right)\,dx$
\nomenclature{$\gamma$}{Euler-Mascheroni constant\nomrefpage}
\include{acronyms}
\end{document}
Best Answer
This has nothing to do with LyX in the first place, it is just
nomencl
’s standard behaviour. The\nomenclature
command just stores the entry for the list, but it does not print any text. However, you can redefine the\nomenclature
command in order to print the text as well. You could, for instance, put the following in the preamble of your document:The first line stores the
\nomenclature
command in\nomenclOrig
. This is necessary, since we have to redefince the\nomenclature
command. This is done in the second line. Since the\nomenclature
command has two mandatory arguments and one optional argument, we have to specify 3 arguments (the[3]
bit). The optional argument has no standard value (the[]
bit). Then we print the second argument (which is the first mandatory argument, since the optional argument is always#1
) as normal text and use the original command that we have stored in\nomenclOrig
.I tried this with LyX, without problems. Note, though, that the two lines will give an error in a document without a nomenclature entry or list, because then LyX will not load the
nomencl
package and thus the\renewcommand
will throw an error.