0

I am struggling to find a solution to changing the section heading of a report document to the upper case while using the \glsfmt* commands of the glossaries-extra package and avoiding the issue where the command also affects the labels. I am using the secsty package and a minimal example of my setup follows:

\documentclass[12pt,a4paper]{report}

    \usepackage[%
        toc=false,
        sort=standard,
        acronyms,
        nopostdot,
        nonumberlist,
        nogroupskip
    ]{glossaries-extra}

    \usepackage{sectsty}
        \sectionfont{\normalsize\bfseries\MakeUppercase}
        \subsectionfont{\normalsize\bfseries}
        \subsubsectionfont{\normalsize\bfseries\itshape}

    \newacronym{tt}{TT}{Test}

\begin{document}

    \chapter{Test with \glsfmtshortpl{tt}}
    \section{Test with \glsfmtshortpl{tt}}
    \subsection{Test with}
    \subsubsection{Test with}

\end{document}

When running that here (using TeX Live 2019/Debian) I get the error:

Package glossaries-extra Error: Glossary entry `TT' has not been defined.

I already tested the titlesec package, and used the \MakeTextUppercase command from the textcase package, but the error still persists. I found some answers explaining the issue behind it, but, as far as I could understand, the new commands provided by glossaries-extra specifically to be used in section headers should be protected against that. Is that correct or should I try to modify the \gls* commands to avoid the error? Alternatively, could the section heading be modified to upper case in a way to avoid it?

Thanks in advance! Iago

1 Answer 1

1

Your code will work by adding \newacronym{tt}{TT}{Test} in the chapter/section titles (and without using \tableofcontents).

a

\documentclass[12pt,a4paper]{report}

\usepackage[%
toc=false,
sort=standard,
acronyms,
nopostdot,
nonumberlist,
nogroupskip
]{glossaries-extra}

\usepackage{sectsty}
\sectionfont{\normalsize\bfseries\MakeUppercase}
\subsectionfont{\normalsize\bfseries}
\subsubsectionfont{\normalsize\bfseries\itshape}    

\begin{document}        

\chapter{Test with \newacronym{tt}{TT}{Test}\glsfmtshortpl{tt}} 

\section{Test with \newacronym{tt}{TT}{Test}\glsfmtshortpl{tt}} 

\subsection{Test with 1}
\subsubsection{Test with 2} 
    
\end{document}

If you want (probably) add a ToC you will need to use

\tableofcontents    

\chapter[Test with TT]{Test with \newacronym{tt}{TT}{Test} \glsfmtshortpl{tt}}      
\section[TEST  WITH  TTs]{Test with \newacronym{tt}{TT}{Test}\glsfmtshortpl{tt}}

otherwise you will get an "already defined" error when processing the ToC.

This avoids the problem by using \section[<text to Toc>]{<text of title>}

See Glossary entry has already been defined

Update after follow-up question: using hyperref and ToC

C

\documentclass[12pt,a4paper]{report}

\usepackage[%
toc=false,
sort=standard,
acronyms,
nopostdot,
nonumberlist,
nogroupskip
]{glossaries-extra}

\usepackage{sectsty}
\sectionfont{\normalsize\bfseries\MakeUppercase}
\subsectionfont{\normalsize\bfseries}
\subsubsectionfont{\normalsize\bfseries\itshape}

\usepackage{hyperref} % add last    

\begin{document}

\tableofcontents    

\chapter[Test with TTs]{Test with \newacronym{tt}{TT}{Test} \glsfmtshortpl{tt}}     
\section[TEST  WITH  TTs]{Test with \newacronym{tt}{TT}{Test}\glsfmtshortpl{tt}}    

\subsection{Test with 1}
\subsubsection{Test with 2} 
    
\end{document}
3
  • Thanks for the answer! It works on the example, but I forgot to mention that I was also using the hyperref package. When I run the same example (with toc) after including hyperref, I get an Undefined control sequence error. Do you know what is wrong in this case? (Btw, I am compiling with XeLaTeX, if that matters. Although I got the same with pdflatex). Commented May 25, 2022 at 20:17
  • @iago.oliveira Thank you for your feedback! Please see the updated answer . Commented May 25, 2022 at 21:06
  • Perfect, thank you very much @Simon! Commented May 25, 2022 at 23:23

You must log in to answer this question.

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