1

I have several issues with the glossaries-extra package that I want to customize. You can find the code and the corresponding output below:

  1. I want to make the list of abbreviations like the list of figures above. There are currently the following differences:

1.1 As you can see, the dot spacing is different, and the dots are not bold.

1.2 In front of the abbreviation is an indentation, which I do not want to have.

1.3 I would like to have the description of the abbreviation flush right.

1.4 I want to change the vertical spacing to 1ex (like in the list of figures)

I know that you can change an existing glossary style with \newglossarystyle, but I could not find the appropriate commands for it. I use the style listdotted. Can I use the following code to customize my top points?

\newglossarystyle{mylist}{
    \setglossarystyle{listdotted} % base this style on the listdotted style
    % change goes here:
    \renewcommand{}{}
}

This code is from here: https://ftp.mpi-inf.mpg.de/pub/tex/mirror/ftp.dante.de/pub/tex/macros/latex/contrib/glossaries/glossaries-user.html#sec:glossarystylecmds

Here you can find all predefined styles, but I think with listdotted I have the least work?: https://www.dickimaw-books.com/gallery/glossaries-styles/

  1. My second problem is with the use of abbreviations in the text. In the output, the target and the actual state is shown.

What I want is that only the first time the abbreviation is used, the short form appears in bold text. All subsequent abbreviations should not be bold.

So: The first time the abbreviation is used, the long form is printed in bold with the initial letters and the short form is printed in brackets and bold after that.

At the second use, only the short form is used and not in bold text.

In the list of abbreviations, the short form should be bold, and the description is defined separately (see code).

I hope it is comprehensible and someone can help me with the customizations!

\documentclass[a4paper, 12pt]{article}
\usepackage{graphicx}
\usepackage[left=2.5cm, right=2.5cm, top=2.75cm, bottom=2cm]{geometry}
\usepackage{tocbasic}
\usepackage[ngerman]{babel}
\usepackage[hidelinks]{hyperref}
\usepackage[toc,nogroupskip,xindy,style=listdotted]{glossaries-extra}

% graphics
\graphicspath{ {./images/} }

% set default font
\usepackage{fontspec}
\setmainfont{Arial}
\newfontfamily\schola{TeX Gyre Schola}
\usepackage{setspace}
\onehalfspacing
% set default indent
\setlength{\parindent}{0pt}

% list of figures
\DeclareTOCStyleEntries[
    beforeskip=1ex,
    linefill=\bfseries\dotfill,
    pagenumberformat=\bfseries\schola,
    pagenumberbox=\pagenumberbox,
    entrynumberformat=\bfseries\figurenumberformat,
    numwidth=7em,
    indent=0em,
]{tocline}{figure}

\newcommand*\pagenumberbox[1]{\mbox{\hspace{0em}#1}}
\newcommand*{\figurenumberformat}[1]{\mbox{Abbildung #1}:}

% list of abbreviations
\makeglossaries
\newabbreviation
[description={Federal Bureau of Investigation -- Investigative and National Security Components}]
{fbi}{\textbf{FBI-INC}}{\textbf{F}ederal \textbf{B}ureau of \textbf{I}nvestigation -- \textbf{I}nvestigative and \textbf{N}ational Security \textbf{C}omponents}

\newabbreviation
[description={LongDescriptionThatExtendsIntoTheMargin}]
{usa}{\textbf{USA}}{\textbf{U}nited \textbf{S}tates of \textbf{A}merica}

\newabbreviation
[description={United States}]
{us}{\textbf{US}}{\textbf{U}nited \textbf{S}tates}
  
\begin{document}

% Table of figures
\addcontentsline{toc}{section}{\listfigurename}
\listoffigures

% List of abbreviations
\printglossary[title={Abkürzungsverzeichnis}]

% TARGET-ACTUAL comparison
\section{TARGET}

First use: The \textbf{F}ederal \textbf{B}ureau of \textbf{I}nvestigation -- \textbf{I}nvestigative and \textbf{N}ational Security \textbf{C}omponents (\textbf{FBI-INC}) protects the \textbf{U}nited \textbf{S}tates (\textbf{US}) (or \textbf{U}nited \textbf{S}tates of \textbf{A}merica (\textbf{USA})) through investigations and national security.

\vspace{\baselineskip}

Second use: The FBI-INC protects the US (or USA) through investigations and national security.

\section{ACTUAL}

First use: The \gls{fbi} protects the \gls{us} (or \gls{usa}) through investigations and national security.

\vspace{\baselineskip}

Second use: The \gls{fbi} protects the \gls{us} (or \gls{usa}) through investigations and national security.

\begin{figure}[ht]
    \centering
    \includegraphics[height=1cm]{overleaf-logo}
    \caption{Caption}
\end{figure}

\end{document}

Code Output

2 Answers 2

1

You've pretty much solved the first part of your question concerning the list in your own answer. The one thing missing is that you can control the vertical separation through redefining the theglossary environment as

\renewenvironment{theglossary}%
    {\glslistinit\begin{description}[itemsep=1ex,parsep=0ex]}%
    {\end{description}}

using enumitem for convenience.

I'm less convinced that redefining \gls is either particularly effective or indeed a good idea at all. The more desirable approach would be to create a custom abbreviationstyle based on the long-short style which uses a bold font explicitly for the abbreviation in the first appearance.

\newabbreviationstyle{mystyle}{%
    \GlsXtrUseAbbrStyleSetup{long-short}%
}{%
    \GlsXtrUseAbbrStyleFmts{long-short}%
    \renewcommand*{\glsfirstabbrvfont}[1]{\textbf{##1}}%
}

The approach is similar for glossaries, redefining \firstacronymfont instead.

Giving in full Compiled code showing similarly formatting list of figures and list of abbreviations, and identically formatted Target and Actual sections

\documentclass[a4paper, 12pt]{article}
\usepackage{graphicx}
\usepackage[left=2.5cm, right=2.5cm, top=2.75cm, bottom=2cm]{geometry}
\usepackage{tocbasic}
\usepackage{enumitem}
\usepackage[toc,nogroupskip,xindy,style=listdotted]{glossaries-extra}

\usepackage{fontspec}
\setmainfont{Arial}
\newfontfamily\schola{TeX Gyre Schola}
\usepackage{setspace}
\onehalfspacing
\setlength{\parindent}{0pt}

\DeclareTOCStyleEntries[
    beforeskip=1ex,
    linefill=\bfseries\dotfill,
    pagenumberformat=\bfseries\schola,
    pagenumberbox=\pagenumberbox,
    entrynumberformat=\bfseries\figurenumberformat,
    numwidth=7em,
    indent=0em,
]{tocline}{figure}

\newcommand*\pagenumberbox[1]{\mbox{\hspace{0em}#1}}
\newcommand*{\figurenumberformat}[1]{\mbox{Abbildung #1}:}

\newglossarystyle{mystyle}{
    \setglossarystyle{list}
    \renewcommand*{\glossentry}[2]{
        \item[\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}}]
        \textbf{\dotfill}
        \raggedleft\glossentrydesc{##1}
    }
    \renewenvironment{theglossary}%
        {\glslistinit\begin{description}[itemsep=1ex,parsep=0ex]}%
        {\end{description}}
}
\newabbreviationstyle{mystyle}{%
    \GlsXtrUseAbbrStyleSetup{long-short}%
}{%
    \GlsXtrUseAbbrStyleFmts{long-short}%
    \renewcommand*{\glsfirstabbrvfont}[1]{\textbf{##1}}%
}
\setabbreviationstyle{mystyle}

\makeglossaries
\newabbreviation
[description={Federal Bureau of Investigation -- Investigative and National Security Components}]
{fbi}{FBI-INC}{\textbf{F}ederal \textbf{B}ureau of \textbf{I}nvestigation -- \textbf{I}nvestigative and \textbf{N}ational Security \textbf{C}omponents}

\newabbreviation
[description={LongDescriptionThatExtendsIntoTheMargin}]
{usa}{USA}{\textbf{U}nited \textbf{S}tates of \textbf{A}merica}

\newabbreviation
[description={United States}]
{us}{US}{\textbf{U}nited \textbf{S}tates}
  
\begin{document}
\listoffigures

\printglossary[style=mystyle,title={Abkürzungsverzeichnis}]

\section{TARGET}

First use: The \textbf{F}ederal \textbf{B}ureau of \textbf{I}nvestigation -- \textbf{I}nvestigative and \textbf{N}ational Security \textbf{C}omponents (\textbf{FBI-INC}) protects the \textbf{U}nited \textbf{S}tates (\textbf{US}) (or \textbf{U}nited \textbf{S}tates of \textbf{A}merica (\textbf{USA})) through investigations and national security.

\vspace{\baselineskip}

Second use: The FBI-INC protects the US (or USA) through investigations and national security.

\section{ACTUAL}

First use: The \gls{fbi} protects the \gls{us} (or \gls{usa}) through investigations and national security.

\vspace{\baselineskip}

Second use: The \gls{fbi} protects the \gls{us} (or \gls{usa}) through investigations and national security.

\begin{figure}[htbp]
    \caption{Caption 1}
\end{figure}
\begin{figure}[htbp]
    \caption{Caption 2}
\end{figure}
\end{document}
3

I have found a solution to the problems I described:

For the first problem:

\newglossarystyle{mystyle}{
    \setglossarystyle{list}
    \renewcommand*{\glossentry}[2]{
        \item[\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}}]
        \textbf{\dotfill}
        \raggedleft\glossentrydesc{##1}
    }
}

with \printglossary[style=mystyle,title={Abkürzungsverzeichnis}] after \begin{document}

This produces my desired output: Output for fixed first problem

BUT: I could not manage to modify the vertical spacing to 1ex.

And the second problem could be fixed with this command:

\renewcommand*{\gls}[1]{%
    \ifglsused{#1}%
        {\glslink{#1}{\glsentryshort{#1}}}%
        {\glsunset{#1}\glslink{#1}{\glsentrylong{#1} (\textbf{\glsentryshort{#1}})}}%
}

As you can see, the target matches now with the actual:

Output fixed for second problem

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .