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.
Make a short form of the caption via \caption[short form]{long form}
. The short form will be printed in the LoF, and shall not contain the \gls
.
To keep the glossaries machinery (links) for the glossary entry intact, use the short form as follows:
\caption[Short form: \protect\glsunset{wysiwyg}\gls{wysiwyg}\protect\glsreset{wysiwyg}]%
{Long form: \gls{wysiwyg}}
The \glsunset
prevents that wysiwyg
becomes a first use glossary entry at this point, the \glsreset
sets the usage counter back, so that any following use of wysiwyg
will be a first use, as far as glossaries
is concerned. This way, the LoF entry will have a hyperlink to the glossary (in addition to being a hyperlink to the figure), the LoF is in the location list of the glossary entry, and you get the formatting of the glossary entry in the LoF as desired.
Somewhat simpler is
\caption[Short form: \glshyperlink{wysiwyg}]{Long form: \gls{wysiwyg}}
This will print the name of the glossary entry in the LoF, hyperlinked to the glossary. You lose the formatting that \gls
applies, and the LoF won't be in the location list of the glossary entry.
Still simpler is
\caption[Short form: \glsentryname{wysiwyg}]{Long form: \gls{wysiwyg}}
This is like the above version, but the LoF line will now link only to the figure, not to the glossary anymore. This form probably suffices for most use cases. It's just that I like that I can link from a glossary term in the LoF to the glossary, and also applying styles to the appearance of glossary entries via \glsdisplay(first)
, which is why I prefer the first form.
Best Answer
I've found this to be the quickest solution for me:
The commands
\glsunsetall
and\glsresetall
have the function to set or reset the so-called first use flag. With the sequence I've written, acronyms in the LoF and LoT are in the short form. Then, thanks to\glsresetall
, they are displayed correctly in the text (first use first, and then the short form).