[Tex/LaTex] Modify appearance of first acronym

acronymsglossaries

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

Best Answer

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}%
  }%
}
Related Question