5

I'd like to have the first occurrence of my acronyms in emphasized style. So, I redefined CustomAcronymFields and use SetCustomStyle, as suggested by the FAQ. This worked til I needed a special treatment for a acronym. I guess the example is self explanatory? (Try it with and without SetCustomStyle.)

\documentclass{scrreprt}
\usepackage[%
  acronym, shortcuts,
  xindy={language=german-duden,codepage=utf8}
]{glossaries}

%see: http://www.dickimaw-books.com/faqs/glossariesfaq.html#longformat
\renewcommand*{\CustomAcronymFields}{%
  name={\the\glsshorttok},% name is abbreviated form
  description={\the\glslongtok},% description is long form
  first={\noexpand\emph{\the\glslongtok\space(\the\glsshorttok)}},%
  firstplural={\noexpand\emph{\the\glslongtok\noexpand\acrpluralsuffix}\space(\the\glsshorttok)},%
  text={\the\glsshorttok},%
  plural={\the\glsshorttok\noexpand\acrpluralsuffix}%
}
\SetCustomStyle

\newacronym[
    longplural={A long Test},
    shortplural={AlT},
    plural={TSTn}]{tst}{TST}{A Test}

\makeglossaries

\begin{document}
This is aspecial long form of \acp{tst}. An the singular of \ac{tst} and it's
plural \acp{tst}.

\printglossary[style=listdotted,type=\acronymtype]{}

\end{document}

What do I have to change, to get the long plural and short plural working?

4

I think in this case it might be better to upgrade to glossaries version 4.0 (which I recently uploaded to CTAN). This has a far more flexible way of changing the displayed format. Example:

\documentclass{scrreprt}
\usepackage[%
  acronym, shortcuts,
  xindy={language=german-duden,codepage=utf8}
]{glossaries}

\renewcommand*{\CustomAcronymFields}{%
  name={\the\glsshorttok},% name is abbreviated form
  description={\the\glslongtok},% description is long form
}

\renewcommand*{\SetCustomDisplayStyle}[1]{%
  \defglsentryfmt[#1]{%
    \ifdefempty\glscustomtext
    {% no custom text supplied
      \ifglsused{\glslabel}%
      {% Subsequent use
        \glsifplural
        {% plural subsequent use
           \glscapscase
           {% no case change
             \glsentryshortpl{\glslabel}\glsinsert 
           }%
           {% first letter upper case
             \Glsentryshortpl{\glslabel}\glsinsert 
           }%
           {% all caps
             \MakeTextUppercase{\glsentryshortpl{\glslabel}\glsinsert}% 
           }%
        }%
        {% singular subsequent use
           \glscapscase
           {% no case change
             \glsentryshort{\glslabel}\glsinsert 
           }%
           {% first letter upper case
             \Glsentryshort{\glslabel}\glsinsert 
           }%
           {% all caps
             \MakeTextUppercase{\glsentryshort{\glslabel}\glsinsert}% 
           }%
        }%
      }%
      {% First use
        \glsifplural
        {% plural first use
          \glscapscase
          {% no case change
            \emph{\glsentrylongpl{\glslabel}\glsinsert\space
               (\glsentryshortpl{\glslabel})}%
          }%
          {% first letter upper case
            \emph{\Glsentrylongpl{\glslabel}\glsinsert\space
               (\glsentryshortpl{\glslabel})}%
          }%
          {% All caps
            \emph{\MakeTextUppercase{%
               \glsentrylongpl{\glslabel}\glsinsert\space
               (\glsentryshortpl{\glslabel})}}%
          }%
        }%
        {% singular first use
          \glscapscase
          {% no case change
            \emph{\glsentrylong{\glslabel}\glsinsert\space
               (\glsentryshort{\glslabel})}%
          }%
          {% first letter upper case
            \emph{\Glsentrylong{\glslabel}\glsinsert\space
               (\glsentryshort{\glslabel})}%
          }%
          {% All caps
            \emph{\MakeTextUppercase{%
               \glsentrylong{\glslabel}\glsinsert\space
               (\glsentryshort{\glslabel})}}%
          }%
        }%
      }%
   }%
   {% custom text provided by \glsdisp
      \ifglsused{\glslabel}%
      {% subsequent use
        \glscustomtext
      }%
      {% first use
        \emph{\glscustomtext}%
      }%
   }%
  }%
}

\SetCustomStyle

\newacronym[
    longplural={A long Test},
    shortplural={AlT}]{tst}{TST}{A Test}

\makeglossaries

\begin{document}
\chapter{Test}

\section{No Case Change}

First use plural: \acp{tst}. Next use plural: \acp{tst}.

\glsresetall

First use singular: \ac{tst}. Next use singular: \ac{tst}.

\glsresetall

\section{First Letter Uppercase}

First use plural: \Acp{tst}. Next use plural: \Acp{tst}.

\glsresetall

First use singular: \Ac{tst}. Next use singular: \Ac{tst}.

\glsresetall

\section{All Caps}

First use plural: \GLSpl{tst}. Next use plural: \GLSpl{tst}.

\glsresetall

First use singular: \GLS{tst}. Next use singular: \GLS{tst}.

\glsresetall

\section{Custom text}

First use: \glsdisp{tst}{sample text}. Next use: \glsdisp{tst}{sample text}.

\printglossary[style=listdotted,type=\acronymtype]{}

\end{document}

This produces:

Image of resulting document

Edit:

As from version 4.02, there's a simpler method:

\documentclass{scrreprt}
\usepackage[%
  acronym, shortcuts,
  xindy={language=german-duden,codepage=utf8}
]{glossaries}

% Define a new acronym style
\newacronymstyle{emfirst-long-short}
{%
  \GlsUseAcrEntryDispStyle{long-short}%
}
{%
  \GlsUseAcrStyleDefs{long-short}%
  \renewcommand*{\genacrfullformat}[2]{%
   \emph{\glsentryshort{##1}##2\space
   (\glsentrylong{##1})}%
  }%
  \renewcommand*{\Genacrfullformat}[2]{%
   \emph{\Glsentryshort{##1}##2\space
   (\glsentrylong{##1})}%
  }%
  \renewcommand*{\genplacrfullformat}[2]{%
   \emph{\glsentryshortpl{##1}##2\space
   (\glsentrylongpl{##1})}%
  }%
  \renewcommand*{\Genplacrfullformat}[2]{%
   \emph{\Glsentryshortpl{##1}##2\space
   (\glsentrylongpl{##1})}%
  }%
}

% Switch to the new acronym style
\setacronymstyle{emfirst-long-short}

\newacronym[
    longplural={A long Test},
    shortplural={AlT}]{tst}{TST}{A Test}

\makeglossaries

\begin{document}
\chapter{Test}

\section{No Case Change}

First use plural: \acp{tst}. Next use plural: \acp{tst}.

\glsresetall

First use singular: \ac{tst}. Next use singular: \ac{tst}.

\glsresetall

\section{First Letter Uppercase}

First use plural: \Acp{tst}. Next use plural: \Acp{tst}.

\glsresetall

First use singular: \Ac{tst}. Next use singular: \Ac{tst}.

\glsresetall

\section{All Caps}

First use plural: \GLSpl{tst}. Next use plural: \GLSpl{tst}.

\glsresetall

First use singular: \GLS{tst}. Next use singular: \GLS{tst}.

\glsresetall

\section{Custom text}

First use: \glsdisp{tst}{sample text}. Next use:
\glsdisp{tst}{sample text}.

\printglossary[style=listdotted,type=\acronymtype]{}

\end{document}

This produces:

Image of resulting document

The only difference is when \glsdisp is used. If you also want this to use \emph on first use, you can modify the above example as follows:

\documentclass{scrreprt}
\usepackage[%
  acronym, shortcuts,
  xindy={language=german-duden,codepage=utf8}
]{glossaries}

% Define a new acronym style
\newacronymstyle{emfirst-long-short}
{%
  \ifglshaslong{\glslabel}%
  {%
     \ifglsused{\glslabel}{\glsgenacfmt}{\emph{\glsgenacfmt}}%
  }%
  {\glsgenentryfmt}% not an acronym
}
{%
  \GlsUseAcrStyleDefs{long-short}%
}

% Switch to the new acronym style
\setacronymstyle{emfirst-long-short}

\newacronym[
    longplural={A long Test},
    shortplural={AlT}]{tst}{TST}{A Test}

\makeglossaries

\begin{document}
\chapter{Test}

\section{No Case Change}

First use plural: \acp{tst}. Next use plural: \acp{tst}.

\glsresetall

First use singular: \ac{tst}. Next use singular: \ac{tst}.

\glsresetall

\section{First Letter Uppercase}

First use plural: \Acp{tst}. Next use plural: \Acp{tst}.

\glsresetall

First use singular: \Ac{tst}. Next use singular: \Ac{tst}.

\glsresetall

\section{All Caps}

First use plural: \GLSpl{tst}. Next use plural: \GLSpl{tst}.

\glsresetall

First use singular: \GLS{tst}. Next use singular: \GLS{tst}.

\glsresetall

\section{Custom text}

First use: \glsdisp{tst}{sample text}. Next use:
\glsdisp{tst}{sample text}.

\printglossary[style=listdotted,type=\acronymtype]{}

\end{document}

This produces:

Image of resulting document

|improve this answer|||||

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.