4

I'm using glossaries to generate my acronyms. Sometimes the first definition of the acronym is placed in a section or chapter title. When I generate the ToC, then obviously that will become the first occurrence and will be expanded, but the acronym in the tile will not. Is it possible to have them expand either in both places or only in the tile, not the ToC? I'd like a general solution, meaning that I don't want to manually reset the glossary before the title where the acronym appears.

Here's a very short example of what I have:

\documentclass{amsbook}

\usepackage[acronym,nonumberlist]{glossaries}
\newacronym{MOSFET}{MOSFET}{metal-oxide semiconductor field-effect transistor}
\makeglossaries

\begin{document}
\tableofcontents
\chapter{\Gls{MOSFET}}
\printglossaries
\end{document}

EDIT: This post is related, but doesn't really do...

2 Answers 2

4
{\let\gls\glsfirst
\let\Gls\Glsfirst
\tableofcontents}

will make it use the expanded form in the title and the toc

2
  • That's nice! I see the braces are essential.
    – Count Zero
    Sep 30, 2012 at 12:00
  • @davidcarlisle is there anyway of not expanding in TOC or titles. The think is otherwise the first time in text is not expanded. For instance, one in toc if I talk about a term in the introduction it is not expanded. Should I use \glsresetall{}?
    – jlanza
    Jan 26, 2014 at 12:14
4

David's answer works fine because your MWE has the location list suppressed (nonumberlist) and doesn't use hyperref. However I thought I'd better add this in case others have a similar problem but need a more general solution that works with the number list and hyperref.

In general it's best not to use commands like \Gls in chapter/section headings. There's more of a problem than just prematurely triggering the first use flag. It will also cause the table of contents to be added to the entry's location list, which isn't particularly helpful to the reader, and can cause nested hyperlinks and problems with PDF bookmarks. Depending on the page style, you can also end up indexing the entry on every page that the chapter/section title appears in the page header.

If you're happy to extend the glossaries package with glossaries-extra, then a better approach is to use commands like \glsfmtshort, \glsfmtlong or \glsfmtfull in the chapter/section heading. For example:

\documentclass{amsbook}

\usepackage{hyperref}
\usepackage[acronym,toc=false]{glossaries-extra}

\makeglossaries

\setabbreviationstyle[acronym]{long-short}
\newacronym{MOSFET}{MOSFET}{metal-oxide semiconductor field-effect
transistor}

\begin{document}
\tableofcontents

\chapter{\Glsfmtfull{MOSFET}}
\printglossaries
\end{document}

See also Entries in Sectioning Titles, Headers, Captions and Contents.

4
  • What is the difference to \acrfull{MOSEFET} of glossaries?
    – jan-glx
    Dec 18, 2017 at 19:29
  • @YAK \acrfull (and \acrshort, \acrlong etc) are designed for the base glossaries package's acronym mechanism. \glsxtrfull (\glsxtrshort, \glsxtrlong etc) are designed for glossaries-extra's abbreviation mechanism which allows different abbreviation styles. The base commands won't reflect the change in style. Commands like \glsfmtfull (\Glsfmtfull, \glsfmtshort etc) are specifically designed for use in section headings. Dec 18, 2017 at 19:53
  • So glossaries-extra is not required to solve the OP's problem but if used \glossaries-extra is?
    – jan-glx
    Dec 18, 2017 at 21:05
  • 1
    @YAK \chapter{\Glsfmtfull{MOSFET}} (from glossaries-extra) is the best solution. With just the base glossaries package, the least problematic solution is \chapter{\Glsentryfull{MOSFET}} or (with hyperref) \chapter{\texorpdfstring{\Glsentryfull{MOSFET}}{\glsentrylong{MOSFET} (\glsentryshort{MOSFET})}}. Dec 18, 2017 at 21:25

You must log in to answer this question.

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