I don't know what this has to do with Lyx, so I ignore that. Second, it might be helpful to know what larger problem you want(-ed) to solve, as the question you linked to seems to achieve the same thing, just without using nomencl
. It might be possible that the still developed glossaries
package is suitable to solve the larger problem at hand.
Having said that, let's start.
To make the group headings larger, we insert a \Large
into the place where you made them bold already:
\renewcommand{\nomgroup}[1]{%
\ifthenelse{\equal{#1}{A}}%
{\item[\textbf{\Large Acronym}]}%
{ \ifthenelse{\equal{#1}{G}}%
{\item[\textbf{\Large Glossary}]}%
{}%
}%
}
To get rid of the "Nomenclature", we patch \thenomenclature
using the etoolbox
package:
\patchcmd{\thenomenclature}{%
\section*{\nomname}
\if@intoc\addcontentsline{toc}{section}{\nomname}\fi%
}{}{}{\message{^^JPatching of thenomenclature failed^^J}}
Note that this will also remove the Nomenclature entry from the Table of Contents, as we don't have a sectioning command anymore. If you are using a chaptered document like book
, the section
s above need to be replaced by chapter
.
To save retyping \thenomenclature
entries, we patch the \@gls@
macro that does all the work when \gls{api}
, \gls*{api}
is called for the first time for an entry. We add the two \nomenclature
calls:
\patchcmd{\@gls@}{%
\glsunset{#2}%
}{%
\ifglsused{#2}{}{%
\nomenclature[a]{\glsentryname{#2}}{\glsentrydesc{#2}}%
\nomenclature[g]{\glsentryname{#2g}}{\glsentrydesc{#2g}}%
}%
\glsunset{#2}%
}{}{\message{^^JPatching of gls failed^^J}}
To get the hyperlinking right, the glossary entry in the nomenclature must become a hypertarget, while the acronym entry in the nomenclature should get a link to this target. The target will be created by using
\nomenclature[g]{\hypertarget{glo:#2}{\glsentryname{#2g}}}{\glsentrydesc{#2g}}%
in the above code.
Creating the link in the acronym entry is harder: one might be tempted to put that directly in the second argument of \nomenclature
call, but this is eaten by makeindex
. Instead, we save label and text of that link into two variables:
\nomenclature[a]{\hyperlink{glo:#2}{\glsentryname{#2}}}{
\glsentrydesc{#2}\def\glolinklabel{glo:#2}\def\glolinktext{\glsentryname{#2}}}%
that can be used afterwards.
To put the link between glossary description and page references, we use
\pretocmd{\nompageref}{%
\ifx\glolinklabel\@empty%
\relax%
\else%
, \textit{Glossary:} \hyperlink{\glolinklabel}{\glolinktext}%
\fi%
}{}{\message{^^JAppending to nompageref failed^^J}}
To put the link after possible page references, we use
\renewcommand{\nomentryend}{%
\ifx\glolinklabel\@empty%
\relax%
\else%
; \textit{Glossary:} \hyperlink{\glolinklabel}{\glolinktext}%
\fi%
}
Result:

Complete MWE:
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
%% the following is useful when we have the old nomencl.sty package
% \usepackage{nomencl}
% \providecommand{\printnomenclature}{\printglossary}
% \providecommand{\makenomenclature}{\makeglossary}
% \makenomenclature
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{kantlipsum}
\usepackage{babel}
\usepackage{ifthen}
\usepackage[debug,colorlinks]{hyperref}
\usepackage[refpage]{nomencl}
% \usepackage{nomencl}
\usepackage{glossaries}
\usepackage{etoolbox}
\makenomenclature
\makeatletter
%% Write name and description to the glossary of the nomenclature.
%% This assumes that only the acronyms are referenced in the text, i.e.,
%% you only use \gls{api}, not \gls{apig}.
%% The glossaries package makes hyperlinks from \gls{<label>} as glo:<label>, so we make
%% corresponding hypertargets at the nomencl--glossary entry.
%% Define the storage here, otherwise hyperref complains.
\def\glolinklabel{}
\def\glolinktext{}
\patchcmd{\@gls@}{%
\glsunset{#2}%
}{%
ifglsused{#2}{}{%
%% acronym entry:
% \nomenclature[a]{\glsentryname{#2}}{
% \glsentrydesc{#2}\def\glolinklabel{glo:#2}\def\glolinktext{\glsentryname{#2}}}%
%% or with another link at the acronym
\nomenclature[a]{\hyperlink{glo:#2}{\glsentryname{#2}}}{
\glsentrydesc{#2}\def\glolinklabel{glo:#2}\def\glolinktext{\glsentryname{#2}}}%
%% does not work:
% \nomenclature[a]{\hyperlink{glo:#2}{\glsentryname{#2}}}{
% \glsentrydesc{#2}\def\glolinklabel{glo:#2}\def\glolinktext{\glsentryname{#2}}; \textit{Glossary: }
% \hyperlink{glo:#2}{\glsentryname{#2}}}%
%% glossary entry:
\nomenclature[g]{\hypertarget{glo:#2}{\glsentryname{#2g}}}{\glsentrydesc{#2g}}%
}%
\glsunset{#2}%
}{}{\message{^^JPatching of gls failed^^J}}
%% At the end of acronym entries (those that define \glolinklabel and \glolinktext), put
%% a link to the corresponding glossary entry after possible page references.
% \renewcommand{\nomentryend}{%
% \ifx\glolinklabel\@empty%
% \relax%
% \else%
% ; \textit{Glossary:} \hyperlink{\glolinklabel}{\glolinktext}%
% \fi%
% }
%% At the end of acronym entries (those that define \glolinklabel and \glolinktext), put
%% a link to the corresponding glossary entry before possible page references.
\pretocmd{\nompageref}{%
\ifx\glolinklabel\@empty%
\relax%
\else%
, \textit{Glossary:} \hyperlink{\glolinklabel}{\glolinktext}%
\fi%
}{}{\message{^^JAppending to nompageref failed^^J}}
\makeatother
%% To get rid of the Nomenclature section title, but this still adds a \section*{}
% \renewcommand{\nomname}{}
%% So remove the section, too. But then we should not write to the ToC, either.
\makeatletter
\patchcmd{\thenomenclature}{%
\section*{\nomname}
\if@intoc\addcontentsline{toc}{section}{\nomname}\fi%
}{}{}{\message{^^JPatching of thenomenclature failed^^J}}
\makeatother
%% Large bold group headings.
\renewcommand{\nomgroup}[1]{%
\ifthenelse{\equal{#1}{A}}%
{\item[\textbf{\Large Acronym}]}%
{ \ifthenelse{\equal{#1}{G}}%
{\item[\textbf{\Large Glossary}]}%
{}%
}%
}
%% glossary entries
\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%
}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\printnomenclature
main text body
first use \gls{api}
\kant[1]
subsequent use of \gls{api}
\kant[2-3]
another use of \gls*{api}
\kant[4-5]
another use of \gls{api}
\end{document}
It may be cleaner to define only one glossaries
entry to prevent accidental usage of the glossary entry apig
. It also makes the code more robust, as we do not depend on the naming scheme api
-> apig
. This can be achieved by using the user1
field for the long description. The only things that need change are the glossary entry generation:
\nomenclature[g]{\hypertarget{glo:#2}{\glsentryname{#2g}}}{\glsentryuseri{#2}}%
(Spot the usage of \glsentryuseri
.) The single entry would look like this:
\newglossaryentry{api}{%
type=\acronymtype,%
name={API},%
description={Application Programming Interface},%
first={Application Programming Interface (API)},%
user1={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},%
% see=[Glossary:]{apig}%
}