Latest news 2019-12-05: new blog post "RSS Feeds and Other Notifications."

Bug Tracker

ID51
StatusClosed (Not a Bug)
Categoryglossaries
Version4.01
SummaryAcronym disables glsentryfmt...

Report

Adding the line makes the custom formatting go away...
\newacronym{apa}{apa}{Apa per Apa}
see the repro code.

Ola Olsson

MWE

\documentclass{article}
\usepackage{glossaries}

\makeglossaries

\renewcommand*{\glsentryfmt}{%
  \glsgenentryfmt
  \ifglsused{\glslabel}{}{\space (\glsentrysymbol{\glslabel})}%
}

\newglossaryentry{distance}{name=distance,
description={The length between two points},
symbol={km}}

\newacronym{apa}{apa}{Apa per Apa}

\begin{document}

First use: \gls{distance}. Next use: \gls{distance}.


\end{document}

Evaluation

This isn't a bug but is a feature of having a mixture of acronyms and regular entries in the same glossary. There are two issues:
  1. As per section Acronym Options in the user manual, you can use the package option acronymlists to identify a glossary that contains acronyms. This sets up the display format for the given glossaries via \defglsentryfmt.

    If \newacronym is used in a glossary that hasn't been identified in this way, then \newacronym will automatically add that glossary to the list of acronyms and will use \defglsentryfmt to setup the display style for that glossary. So to prevent \newacronym from overriding the display style for a particular glossary you need to have already identified that glossary as a list of acronyms using the acronymlists package option (or the equivalent \DeclareAcronymList command).

    \usepackage[acronymlists=main]{glossaries}
    
    or
    \DeclareAcronymList{main}
    
  2. Redefining \glsentryfmt only has an effect on glossaries that haven't had their display style changed via \defglsentryfmt. Since using all acronyms set their display style using \defglsentryfmt, the only way to change their style is to use \defglsentryfmt rather than redefining \glsentryfmt. So you would need to do:
    \defglsentryfmt{%
      \glsgenentryfmt
      \ifglsused{\glslabel}{}{\space (\glsentrysymbol{\glslabel})}%
    }
    
    However, this will interfere with the way the acronyms are displayed so \gls{apa} will produce "Apa per Apa (apa) ()" which has an unwanted set of parentheses. Instead you need to modify the argument of \defglsentryfmt so that it checks if the entry is an acronym:
    \defglsentryfmt{%
      \glsgenentryfmt
      \ifglshaslong{\glslabel}%
      {}% this entry is an acronym so do nothing
      {\ifglsused{\glslabel}{}{\space (\glsentrysymbol{\glslabel})}}%
    }
    
The complete document is now:
\documentclass{article}
\usepackage[acronymlists=main]{glossaries}

\makeglossaries

\defglsentryfmt{%
  \glsgenentryfmt
  \ifglshaslong{\glslabel}%
  {}% this entry is an acronym so do nothing
  {\ifglsused{\glslabel}{}{\space (\glsentrysymbol{\glslabel})}}%
}

\newglossaryentry{distance}{name=distance,
description={The length between two points},
symbol={km}}

\newacronym{apa}{apa}{Apa per Apa}

\begin{document}

First use: \gls{distance}. Next use: \gls{distance}.

Acronym first use: \gls{apa}. Next use: \gls{apa}.
\end{document}
If you choose to upgrade to version 4.02, there's another approach:
\documentclass{article}
\usepackage[acronymlists=main]{glossaries}

\makeglossaries

\newacronymstyle
 {my-custom-style}% style name
 {% display
   \ifglshaslong{\glslabel}%
   {\glsgenacfmt}% acronym
   {% not an acronym
      \glsgenentryfmt
      \ifglsused{\glslabel}{}{\space (\glsentrysymbol{\glslabel})}%
   }%
 }%
 {% style definitions
   \GlsUseAcrStyleDefs{long-short}% use the same style as 'long-short'
 }

% switch to this new style:
\setacronymstyle{my-custom-style}

\newglossaryentry{distance}{name=distance,
description={The length between two points},
symbol={km}}

\newacronym{apa}{apa}{Apa per Apa}

\begin{document}

First use: \gls{distance}. Next use: \gls{distance}.

Acronym: \gls{apa}. \gls{apa}.
\end{document}

Add comment.

Watch This Report

If you would like to be notified whenever updates are made to this report, please fill in your email address in the box below and click on "Notify Me of Changes" button. (Please ensure the address is valid.) Your details won't be passed on to third parties in line with this site's Privacy Policy.

If you supply your name, it will be used in the email greeting, which provides a more personal message, otherwise you'll just get a generic greeting. If you have previously supplied your name when signing up for notifications, you don't need to resupply it unless you want to change it.

If you have previously subscribed to notifications for this report, you can unsubscribe by clicking on the "Stop Notification" button.

The "Confirm Bug ID" field helps to protect against spambots. Please enter the bug ID (which you can find at the top of this page).

(Optional.)
E mail:
Confirm E mail:
Confirm Bug ID:

To unsubscribe from all notifications use the notifications page.

Comment

You can append a comment to the report using the form below. Comments are checked first before being added. Any spam or offensive content will be removed first according to this site's Terms of Website Use. Please bear in mind that I develop and maintain free software in my spare time. If you want commerical level support then you can hire a TeX consultant.

The "Confirm Bug ID" field helps to protect against spambots. Please enter the bug ID (which you can find at the top of this page).

(Optional. If provided, it will be shown with the comment.)
Confirm Bug ID:

You can use the following markup:

[pre]Displayed verbatim[/pre]
[tt]monospace text[/tt]
[em]emphasized text[/em]
[b]bold text[/b]
[url]web address[/url]

Ordered list:
[ol]
[li]first item[/li]
[li]second item[/li]
[/ol]

Unordered list:
[ul]
[li]first item[/li]
[li]second item[/li]
[/ul]

Click on the Preview button to preview the message.

Return to list.

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

Terms of Use Privacy Policy Cookies Site Map FAQs