# Gallery: Mixed Glossary with Emphasis

If you have a small screen, you may prefer to switch on the small image setting.

This example is a modification of Mixed Glossary, but in this case the first use (of \gls) is emphasized completely for regular terms and partially for abbreviations (only the long form is emphasized not the short form). The full form for abbreviations aren’t emphasized nor is there any emphasis in the glossary.

A far simpler method can be obtained with glossaries-extra. See Mixed Glossary with Emphasis (glossaries-extra.sty).

This example requires defining a new acronym style, which I’ve labelled long-short-emph:

\newacronymstyle{long-short-emph}%
{%
\ifglshaslong{\glslabel}%
{% acronym
% This is an adaptation of \glsgenacfmt
\ifdefempty\glscustomtext
{%
\ifglsused\glslabel
{%
\glsifplural
{%
\glscapscase
{%
\acronymfont{\glsentryshortpl{\glslabel}}\glsinsert
}%
{%
\acronymfont{\Glsentryshortpl{\glslabel}}\glsinsert
}%
{%
\mfirstucMakeUppercase
{\acronymfont{\glsentryshortpl{\glslabel}}\glsinsert}%
}%
}%
{%
\glscapscase
{%
\acronymfont{\glsentryshort{\glslabel}}\glsinsert
}%
{%
\acronymfont{\Glsentryshort{\glslabel}}\glsinsert
}%
{%
\mfirstucMakeUppercase
{\acronymfont{\glsentryshort{\glslabel}}\glsinsert}%
}%
}%
}%
{%
\glsifplural
{%
\glscapscase
{%
\emph{\glsentrylongpl{\glslabel}\glsinsert}\space
(\firstacronymfont{\glsentryshortpl{\glslabel}})%
}%
{%
\emph{\Glsentrylongpl{\glslabel}{\glsinsert}}\space
(\firstacronymfont{\glsentryshortpl{\glslabel}})%
}%
{%
\mfirstucMakeUppercase
{\emph{\glsentrylongpl{\glslabel}{\glsinsert}}\space
(\firstacronymfont{\glsentryshortpl{\glslabel}})}%
}%
}%
{%
\glscapscase
{%
\emph{\glsentrylong{\glslabel}\glsinsert}\space
(\firstacronymfont{\glsentryshort{\glslabel}})%
}%
{%
\emph{\Glsentrylong{\glslabel}\glsinsert}\space
(\firstacronymfont{\glsentryshort{\glslabel}})%
}%
{%
\mfirstucMakeUppercase
{\emph{\glsentrylong{\glslabel}\glsinsert}\space
(\firstacronymfont{\glsentryshort{\glslabel}})}%
}%
}%
}%
}%
{%
\glscustomtext
}%
}%
{% regular term
\ifglsused{\glslabel}{\glsgenentryfmt}{\emph{\glsgenentryfmt}}%
}%
}%
{%
\GlsUseAcrStyleDefs{long-short}%
}


Note that the full form used by \acrfull doesn’t emphasize the long form. The style checks if the entry is an acronym using \ifglshaslong.

You can, of course, make this example style more generic by defining a formatting command, such as:

\newcommand*{\firstformat}[1]{\emph{#1}}


and then use that command instead of \emph in the style definition.

Note that if you want the emphasis to also apply to the abbreviation as well as the long form, then the second argument of \newacronymstyle is much simpler:

  \ifglsused{\glslabel}%
{\ifglshaslong{\glslabel}{\glsgenacfmt}{\glsgenentryfmt}}%
{\emph{\ifglshaslong{\glslabel}{\glsgenacfmt}{\glsgenentryfmt}}}%


The initial comment lines below are arara directives. You can remove them if you don’t use arara.

% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex
\documentclass{article}

\usepackage[toc,acronymlists={main}]{glossaries}
\usepackage{glossary-mcols}

\makeglossaries

\newacronymstyle{long-short-emph}%
{%
\ifglshaslong{\glslabel}%
{% acronym
% This is an adaptation of \glsgenacfmt
\ifdefempty\glscustomtext
{%
\ifglsused\glslabel
{%
\glsifplural
{%
\glscapscase
{%
\acronymfont{\glsentryshortpl{\glslabel}}\glsinsert
}%
{%
\acronymfont{\Glsentryshortpl{\glslabel}}\glsinsert
}%
{%
\mfirstucMakeUppercase
{\acronymfont{\glsentryshortpl{\glslabel}}\glsinsert}%
}%
}%
{%
\glscapscase
{%
\acronymfont{\glsentryshort{\glslabel}}\glsinsert
}%
{%
\acronymfont{\Glsentryshort{\glslabel}}\glsinsert
}%
{%
\mfirstucMakeUppercase
{\acronymfont{\glsentryshort{\glslabel}}\glsinsert}%
}%
}%
}%
{%
\glsifplural
{%
\glscapscase
{%
\emph{\glsentrylongpl{\glslabel}\glsinsert}\space
(\firstacronymfont{\glsentryshortpl{\glslabel}})%
}%
{%
\emph{\Glsentrylongpl{\glslabel}{\glsinsert}}\space
(\firstacronymfont{\glsentryshortpl{\glslabel}})%
}%
{%
\mfirstucMakeUppercase
{\emph{\glsentrylongpl{\glslabel}{\glsinsert}}\space
(\firstacronymfont{\glsentryshortpl{\glslabel}})}%
}%
}%
{%
\glscapscase
{%
\emph{\glsentrylong{\glslabel}\glsinsert}\space
(\firstacronymfont{\glsentryshort{\glslabel}})%
}%
{%
\emph{\Glsentrylong{\glslabel}\glsinsert}\space
(\firstacronymfont{\glsentryshort{\glslabel}})%
}%
{%
\mfirstucMakeUppercase
{\emph{\glsentrylong{\glslabel}\glsinsert}\space
(\firstacronymfont{\glsentryshort{\glslabel}})}%
}%
}%
}%
}%
{%
\glscustomtext
}%
}%
{% regular term
\ifglsused{\glslabel}{\glsgenentryfmt}{\emph{\glsgenentryfmt}}%
}%
}%
{%
\GlsUseAcrStyleDefs{long-short}%
}

\setacronymstyle{long-short-emph}

\begin{document}

\section{First Use}

Regular entries: \gls{ac}, \gls{accumsan}, \gls{amet},
\gls{bibendum}, \gls{consectetuer}, \gls{diam}.

Acronyms: \gls{aeu}, \gls{afm}, \gls{anp}, \gls{cas},
\gls{cdg}, \gls{cea}, \gls{dia}.

\section{Next Use}

Regular entries: \gls{ac}, \gls{accumsan}, \gls{amet},
\gls{bibendum}, \gls{consectetuer}, \gls{diam}.

Acronyms: \gls{aeu}, \gls{afm}, \gls{anp}, \gls{cas},
\gls{cdg}, \gls{cea}, \gls{dia}.

Full form: \acrfull{aeu}.

\printglossary[style=mcolindex]

\end{document}


This document loads the hyperref package, which creates hyperlinks from the entries in the document (referenced using commands like \gls) to their definition in the glossary. These hyperlinks are displayed in red text.

The entries have all been defined in the files example-glossaries-brief.tex and example-glossaries-acronym.tex, which you should find installed in the same location as the glossaries package (or in a sub-directory called test-entries). I’ve only used a subset of these entries within the document.

If you don’t use arara, you need to run the following commands:

pdflatex mixed-glossary-emph
makeglossaries mixed-glossary-emph
pdflatex mixed-glossary-emph


I’ve used the toc option to add the glossary to the table of contents. The entries all have a “1” after the description. This is the page number on which the entry was referenced. In this sample document all the entries were referenced on page 1. If you don’t want these numbers you can use the nonumberlist option.

Download: PDF (54.41K), source code (3.00K), sample entry definitions (3.33K), sample acronym definitions (2.83K).

© 2019 Dickimaw Books. "Dickimaw", "Dickimaw Books" and the Dickimaw parrot logo are trademarks. The Dickimaw parrot was painted by Magdalene Pritchett.