3

I want to modify the appearance of the first display of an acronym. I have tried:

\usepackage[toc,xindy]{glossaries}
\newcommand*{\glossfirstformat}[1]{\textit{#1}}
\defglsentryfmt{\glossfirstformat{\glsgenentryfmt}} %Does work
\defglsentryfmt[\acronymtype]{\glossfirstformat{\glsgenentryfmt}} %Does not have any effect

Addendum:

It seems like \acronymtype is only defined if the option acronym is used to the glossariespackage. But I want to have only one glossary including acronyms. I use the trick

\usepackage{xparse}
\DeclareDocumentCommand{\newdualentry}{ O{} O{} m m m m }{
    \newglossaryentry{gls-#3}{name={#5},text={#5\glsadd{#3}},description={#6},#1}
    \newacronym[see={[Glossary:]{gls-#3}},#2]{#3}{#4}{#5\glsadd{gls-#3}}
}

How to solve it in this case?

Addendum 2:

The current proposed solution brakes the formatting rule for the other entries. To be clarify what I want:

enter image description here

  • What do you want to display when the acronym is used for the first time? It's not clear from your question. Also, is the change supposed for a single acronym or for all of them? – karlkoeller Mar 12 '15 at 10:28
  • @karlkoeller All of them, and the full name in italics. – user877329 Mar 12 '15 at 10:41
  • If you don't use the acronym package option, \acronymtype defaults to the main glossary so \defglsentryfmt[\acronymtype]{...} becomes equivalent to \defglsentryfmt{...}. Do you want something like this example? – Nicola Talbot Mar 14 '15 at 17:43
5

For the acronyms, you can define a new style

\newacronymstyle{myacro}
{%
  \GlsUseAcrEntryDispStyle{long-short}%
}%
{%
  \GlsUseAcrStyleDefs{long-short}%
  \renewcommand*{\genacrfullformat}[1]{%
   \glossfirstformat{\glsentrylong{##1}}\space
   (\glsentryshort{##1})%
  }%
  \renewcommand*{\Genacrfullformat}[2]{%
   \glossfirstformat{\Glsentrylong{##1}}\space
   (\glsentryshort{##1})%
  }%
  \renewcommand*{\genplacrfullformat}[2]{%
   \glossfirstformat{\glsentrylongpl{##1}}\space
   (\glsentryshortpl{##1})%
  }%
  \renewcommand*{\Genplacrfullformat}[2]{%
   \glossfirstformat{\Glsentrylongpl{##1}}\space
   (\glsentryshortpl{##1})%
  }%
}

and then use it with

\setacronymstyle{myacro}

For normal glossary entries, you can define

\defglsentryfmt{%
  \ifglshaslong{\glslabel}{%
    \glsgenacfmt%
  }{%
    \ifglsused{\glslabel}{%
      \glsgenentryfmt%
    }{%
      \glossfirstformat{\glsgenentryfmt}%
    }%
  }%
}

MWE:

% arara: pdflatex: {synctex: yes}
% arara: makeglossaries
% arara: pdflatex: {synctex: yes}
% arara: pdflatex: {synctex: yes}

\documentclass{article}

\usepackage[toc]{glossaries}

\newcommand*{\glossfirstformat}[1]{\textit{#1}}

\newacronymstyle{myacro}
{%
  \GlsUseAcrEntryDispStyle{long-short}%
}%
{%
  \GlsUseAcrStyleDefs{long-short}%
  \renewcommand*{\genacrfullformat}[1]{%
   \glossfirstformat{\glsentrylong{##1}}\space
   (\glsentryshort{##1})%
  }%
  \renewcommand*{\Genacrfullformat}[2]{%
   \glossfirstformat{\Glsentrylong{##1}}\space
   (\glsentryshort{##1})%
  }%
  \renewcommand*{\genplacrfullformat}[2]{%
   \glossfirstformat{\glsentrylongpl{##1}}\space
   (\glsentryshortpl{##1})%
  }%
  \renewcommand*{\Genplacrfullformat}[2]{%
   \glossfirstformat{\Glsentrylongpl{##1}}\space
   (\glsentryshortpl{##1})%
  }%
}

\setacronymstyle{myacro}

\defglsentryfmt{%
  \ifglshaslong{\glslabel}{%
    \glsgenacfmt%
  }{%
    \ifglsused{\glslabel}{%
      \glsgenentryfmt%
    }{%
      \glossfirstformat{\glsgenentryfmt}%
    }%
  }%
}

\makeglossaries

\newacronym{AAA}{aaa}{acronym description}
\newglossaryentry{BBB}
{
  name={glossary name},
  description={glossary description},
}


\begin{document}

First use of acronym: \gls{AAA}, and second use: \gls{AAA}.

First use of glossary: \gls{BBB}, and second use: \gls{BBB}.

\printglossaries

\end{document} 

Output:

enter image description here

If normal glossary entries have always to be typeset in italic (not only at their first use), change the above \defglsentryfmt to

\defglsentryfmt{%
  \ifglshaslong{\glslabel}{%
    \glsgenacfmt%
  }{%
    \glossfirstformat{\glsgenentryfmt}%
  }%
}
  • ...or have a look at my latest edit. The regular item is a plain \newglossaryentry [believed to be implicit since the question does not state something else]. – user877329 Mar 12 '15 at 13:32
  • Works perfectly. – user877329 Mar 14 '15 at 9:10
  • @user877329 Happy about that. – karlkoeller Mar 14 '15 at 9:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.