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.
Best Answer
This is a solution.
Use a fixed width when issuing
\printnomenclature
(e.g.2cm
):and define a new glossary style
mylong
where you use the same width (2cm
)When you print your glossary use the above style:
MWE:
Output: