2

I have three groups of acronyms (one main called "List of Abbreviations" and two other groups with their own titles, "Time" and "Cities") in the frontmatter of my document, and I am using the "acronym" from the glossaries package following this example Customising glossary group titles.

\documentclass{article}
\usepackage{hyperref}

\usepackage[acronym,acronymlists={general}, nomain,makeindex]{glossaries}

% new glossary style
\newglossarystyle{onecol}{%
%
\renewenvironment{theglossary}%
{\begin{description}}{\end{description}}%
%
%
% indicate what to do at the start of each logical group
\renewcommand*{\glsgroupheading}[1]{%
\item[{\glsgetgrouptitle{##1}}]}
%
\renewcommand*{\glsgroupskip}{ \\}%
\renewcommand*{\glossaryentryfield}[5]{%
\item[\glstarget{##1}{##2}] ##3%
}%
}

%% glossary
\newglossary{general}{general.sys}{general.syo}{List of Abbreviations}

\newcommand*{\Agroupname}{}
\newcommand*{\Ggroupname}{Cities}
\newcommand*{\Sgroupname}{Time}

% This entry is part of the main glossary
\newglossaryentry{orange}{name=orange, description={an orange coloured fruit},first={Orange}, type={general}, sort=a}

% Entries for first group
\newglossaryentry{utc}{name=UTC, description={Coordinated Universal Time},first={Coordinated Universal Time (UTC)}, type={general}, sort=g}
\newglossaryentry{adt}{name=ADT, description={Atlantic Daylight Time},first={Atlantic Daylight Time (ADT)}, type={general}, sort=g}

% Entries for second group
\newglossaryentry{la}{name=LA, description={Los Angeles},first={Los Angeles (LA)}, type={general}, sort=s}
\newglossaryentry{ny}{name=NY, description={New York},first={New York (NY)}, type={general}, sort=s}

\makeglossaries

\begin{document}


\listoffigures  % print list of figures
\listoftables  % print list of tables
\glsaddall
\clearpage
\phantomsection
\addcontentsline{toc}{chapter}{List of Abbreviations}


\printglossary[type={general},style={onecol}]


\chapter{Introduction}

% Use the acronyms
\gls{utc} is 3 hours behind \gls{adt}.
\gls{ny} is 3 hours ahead of \gls{la}.

\end{document}

I am trying to have a slightly different font for the items that belong to different groups, with the items for example belonging to a group displayed in the short version as \texttt{acronym}. Right now I am doing this by formatting directly the name of each item like this:

\newglossaryentry{utc}{name=\textsf{UTC}, description={Coordinated Universal Time},first={Coordinated Universal Time (UTC)}, type={general}, sort=a}

I have looked through the grouping functions in the manual of the glossaries package but when I try for example \renewcommand*{\acronymfont}[1]{\textsf{#1}} inside the \newglossarystyle definitions this changes all of the formatting. How can I change fonts and sizes independently for each group? Thanks very much for any suggestions!

  • Your MWE does not seem to compile for me. For example, the article class does not have a \chapter macro. – Steven B. Segletes Aug 12 '15 at 12:08
1

I think it's simpler to use the hierarchical mechanism for this type of thing, rather than trying force the entry groups. Also, it can also simplify things to define semantic commands. For example:

\documentclass{report}

\usepackage[T1]{fontenc}
\usepackage[hidelinks]{hyperref}

\usepackage[acronym,acronymlists={general},nomain,makeindex,toc]{glossaries}

% new glossary style
\newglossarystyle{onecol}{%
%
\renewenvironment{theglossary}%
{\begin{description}}{\end{description}}%
%
%
% indicate what to do at the start of each logical group
\renewcommand*{\glsgroupheading}[1]{}
%
\renewcommand*{\glossentry}[2]{%
\item[\glstarget{##1}{\glossentryname{##1}}] \glossentrydesc{##1} ##2%
}%
\renewcommand*{\subglossentry}[3]{%
\item[\glstarget{##2}{\glossentryname{##2}}] \glossentrydesc{##2} ##3%
}%
}

\renewcommand*{\glsnamefont}[1]{\textmd{#1}}

%% glossary
\newglossary{general}{general.sys}{general.syo}{List of Abbreviations}

\newglossaryentry{main}{name={\null},description={\nopostdesc},
 type={general},nonumberlist}
\newglossaryentry{cities}{name={Cities},description={\nopostdesc},
 type={general},nonumberlist}
\newglossaryentry{time}{name={Time},description={\nopostdesc},
 type={general},nonumberlist}

% This entry is part of the main glossary

\newglossaryentry{orange}{name=orange, description={an orange
coloured fruit},first={Orange}, type={general}, parent=main}

% Entries for first group

\newcommand*{\timefont}[1]{\textit{#1}}

\newcommand*{\newtime}[3]{%
  \newglossaryentry{#1}{name={\timefont{#2}},sort={#2},description={#3},
    first={#3 (\timefont{#2})},type={general},parent=time}%
}

\newtime{utc}{UTC}{Coordinated Universal Time}
\newtime{adt}{ADT}{Atlantic Daylight Time}

% Entries for second group

\newcommand*{\cityfont}[1]{\textsf{#1}}

\newcommand*{\newcity}[3]{%
  \newglossaryentry{#1}{name={\cityfont{#2}},sort={#2},description={#3},
    first={#3 (\cityfont{#2})},type={general},parent=cities}%
}

\newcity{la}{LA}{Los Angeles}
\newcity{ny}{NY}{New York}

\makeglossaries

\begin{document}

\glsaddall

\printglossary[type={general},style={onecol}]

\chapter{Introduction}

% Use the acronyms
\gls{utc} is 3 hours behind \gls{adt}.
\gls{ny} is 3 hours ahead of \gls{la}.

\end{document}

This redefines \glsnamefont to counteract the bold introduced by \item, and defines two commands \timefont and \cityfont, which are used for the different formatting of the time and city entries. You can modify these as appropriate. You may also want to do something similar for the orange entry.

This produces the glossary:

image of glossary

and the main document text:

image of first chapter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.