Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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

share|improve this answer
    
Thank you very much! It works like a charm. –  daniel Nov 17 '13 at 10:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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