2

In the past I have extensively used the glossaries package. Now I'm trying to use acronyms, where the letters to build up the acronym are underscored in the list of acronyms. In the text I want \gls on first use to display the abbreviation with a footnote text of his description, where the description is linked to the corresponding entry in the list of acronyms:

\acronymfont{<abbrv>}\footnote{<description>}

In the list of acronyms I want the normal display of the abbreviation and the long form together with the number list. The main difference is therefore, that in the footnote the long form is not displayed but the description, which is given as an optional argument for \newacronym.

Is this possible via the help of \CustomAcronymFields, \SetCustomDisplayStyle and/or \SetCustomStyle?

1
  • There's a sample file that comes with the glossaries package called sample-custom-acronym.tex that might be a starting point. (You can use it as a MWE if you want it adjusted.) Sep 23, 2013 at 10:20

1 Answer 1

3

If you want to define a custom acronym style, I strongly recommend you upgrade to at least v4.02. If you do, you can try the following:

\documentclass{article}

\usepackage[colorlinks]{hyperref}
\usepackage[acronym]{glossaries}

\makeglossaries

\newacronymstyle{custom-fn}% new style name
{% Check for long form in case of a mixed glossary
  \ifglshaslong{\glslabel}{\glsgenacfmt}{\glsgenentryfmt}%
}%
{% Style definitions:
 % User needs to supply the description:
 \renewcommand*{\GenericAcronymFields}{}%
 % Need to ensure hyperlinks are switched off on first use:
 \glshyperfirstfalse
 % Redefine the commands used by \glsgenacfmt on first use:
  \renewcommand*{\genacrfullformat}[2]{%
   \firstacronymfont{\glsentryshort{##1}}##2%
   \footnote{\glshyperlink[\glsentrydesc{##1}]{##1}}%
  }%
  \renewcommand*{\Genacrfullformat}[2]{%
   \firstacronymfont{\Glsentryshort{##1}}##2%
   \footnote{\glshyperlink[\glsentrydesc{##1}]{##1}}%
  }%
  \renewcommand*{\genplacrfullformat}[2]{%
   \firstacronymfont{\glsentryshortpl{##1}}##2%
   \footnote{\glshyperlink[\glsentrydesc{##1}]{##1}}%
  }%
  \renewcommand*{\Genplacrfullformat}[2]{%
   \firstacronymfont{\Glsentryshortpl{##1}}##2%
   \footnote{\glshyperlink[\glsentrydesc{##1}]{##1}}%
  }%
 % Redefine the no-link full forms:
  \renewcommand*{\glsentryfull}[1]{%
    \glsentrylong{##1}\space(\acronymfont{\glsentryshort{##1}})%
  }%
  \renewcommand*{\Glsentryfull}[1]{%
    \Glsentrylong{##1}\space(\acronymfont{\glsentryshort{##1}})%
  }%
  \renewcommand*{\glsentryfullpl}[1]{%
    \glsentrylongpl{##1}\space(\acronymfont{\glsentryshortpl{##1}})%
  }%
  \renewcommand*{\Glsentryfullpl}[1]{%
    \Glsentrylongpl{##1}\space(\acronymfont{\glsentryshortpl{##1}})%
  }%
 % Redefine the link full forms:
  \renewcommand*{\acrfullfmt}[3]{%
    \glslink[##1]{##2}{%
     \glsentrylong{##2}##3\space(\acronymfont{\glsentryshort{##2}})%
    }%
  }%
  \renewcommand*{\Acrfullfmt}[3]{%
    \glslink[##1]{##2}{%
     \Glsentrylong{##2}##3\space(\acronymfont{\glsentryshort{##2}})%
    }%
  }%
  \renewcommand*{\ACRfullfmt}[3]{%
    \glslink[##1]{##2}{%
     \MakeTextUppercase{%
       \glsentrylong{##2}##3\space
         (\acronymfont{\glsentryshort{##2}})%
     }%
    }%
  }%
  \renewcommand*{\acrfullplfmt}[3]{%
    \glslink[##1]{##2}{%
     \glsentrylongpl{##2}##3\space
       (\acronymfont{\glsentryshortpl{##2}})%
    }%
  }%
  \renewcommand*{\Acrfullplfmt}[3]{%
    \glslink[##1]{##2}{%
     \Glsentrylongpl{##2}##3\space
       (\acronymfont{\glsentryshortpl{##2}})%
    }%
  }%
  \renewcommand*{\ACRfullplfmt}[3]{%
    \glslink[##1]{##2}{%
     \MakeTextUppercase{%
       \glsentrylongpl{##2}##3\space
         (\acronymfont{\glsentryshortpl{##2}})%
     }%
    }%
  }%
 % Don't apply any font change for the acronym in the document text:
  \renewcommand*{\acronymfont}[1]{##1}%
  \renewcommand*{\acrpluralsuffix}{\glspluralsuffix}%
 % Sort acronyms according to the short form:
  \renewcommand*{\acronymsort}[2]{##1}%
}

 % Now set the new acronym style (to override the default style)
\setacronymstyle{custom-fn}


 % Define a glossary style that will display the short form followed
 % by the long form.

\newglossarystyle{custom-fn}%
{%
  % base it on the long style
  \setglossarystyle{long}%
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glsentryshort{##1}} &
    \glsentrylong{##1}\glspostdescription\space ##2\tabularnewline
  }%
}

 % Now define the acronyms (must be done after setting the custom
 % style)

\newacronym[description={set of tags for use in developing hypertext
documents}]{html}{html}{\underline{h}yper \underline{t}ext 
\underline{m}arkup \underline{l}anguage}


\begin{document}
\gls{html}.

\printglossary[type=acronym,style=custom-fn]
\end{document}

The produces:

Image of resulting page

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .