The question How to combine Acronym and Glossary shows us how to make a great glossaries and acronym lists. I would like to use a quality glossary and acronym list in Lyx.
This may be too large a question to ask all at once. I have broken a possible first step, combining use of nomenclature and glossary. I am trying to use two packages together:
nomenclature
to render the glossary and acronym list in Lyxglossaries
to use the full name the first time it is used in the text and the acronym after.
My attempt is shown below:
%% LyX 1.6.7 created this file. For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{nomencl}
% the following is useful when we have the old nomencl.sty package
\providecommand{\printnomenclature}{\printglossary}
\providecommand{\makenomenclature}{\makeglossary}
\makenomenclature
\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{hyperref}
\usepackage{glossaries}
\usepackage{nomencl}
\makeglossary
\makenomenclature
\RequirePackage{ifthen}
\renewcommand{\nomgroup}[1]{
\ifthenelse{\equal{#1}{A}}
{\item[\textbf{Acronym}]}
{ \ifthenelse{\equal{#1}{G}}
{\item[\textbf{Glossary}]}{}}
}
\makeatother
\usepackage{babel}
\begin{document}
\newglossaryentry{api}{%
type=\acronymtype,
name={API},
description={Application Programming Interface},
first={Application Programming Interface (API)},
see=[Glossary:]{apig}
}
%%% The glossary entry the acronym links to
\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%
}}
\nomenclature[a]{API}{Application Programming Interface}
\nomenclature[g]{API}{%
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%
}
\printnomenclature{}
main text body
first use \gls{api}
subsequent use of \gls{api}
\end{document}
Now how can I create a macro to automatically use all the glossary entries in nomenclature to render the printed glossary. Right now I am typing them twice, as you can see. Bonus points if you can get rid of the "Nomenclature" heading and make the Acronym and Glossary headings larger. Extra special bonus points if you can somehow get the links to work properly, for example, between an acronym and its corresponding glossary entry. I will check if the solutions provided render in Lyx.
Best Answer
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:
The generating the index files for the
glossaries
package uses different options than for thenomencl
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 bychmod u+x mkgloss.sh
for windows, (caution: not tested!) save the file as
mkgloss.bat
in your home directoryWe 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,or for windows,
Usage
Now, we can write acroyms and a glossary entries in the LyX document by using TeX code/ERT (Ctrl-L). For example,
In the LyX document
\gls{api}
as TeX code/ERT will use the glossary entryapi
and\glsadd{apig}
will add the entryapig
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:
By changing the description of this entry LyX will get reminded to update glossary and acronym list.