Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Glossaries: acronymfont

47 views
Skip to first unread message

Leo

unread,
Nov 17, 2009, 12:49:06 PM11/17/09
to
Hi there,

In the following example, I'd like \gls{gnu} to be typeset as
\textsc{gnu} while \Gls{gnu} as \textsc{Gnu} given that the abbreviation
is in uppercase. How can this be done? Thank you very much. - Leo

================================
\documentclass{article}
\usepackage[colorlinks]{hyperref}
\usepackage[nomain,acronym,footnote]{glossaries}
\makeglossaries
\makeatletter
\defglsdisplayfirst[\acronymtype]{%
#2#4 (\protect\glslink[\@gls@link@opts]{\@gls@link@label}
{\firstacronymfont{#1}})}%
\makeatother
\renewcommand*\acronymfont[1]{\textsc{\MakeLowercase{#1}}}
\newacronym{gnu}{GNU}{gnu is not unix}
\begin{document}
\Gls{gnu}.

\Gls{gnu}.

\gls{gnu}
\printglossaries
\end{document}
================================

--
Emacs uptime: 56 days, 8 hours, 59 minutes, 37 seconds

Nicola Talbot

unread,
Nov 17, 2009, 2:44:55 PM11/17/09
to
On Nov 17, 5:49 pm, Leo <sdl....@gmail.com> wrote:
> Hi there,
>
> In the following example, I'd like \gls{gnu} to be typeset as
> \textsc{gnu} while \Gls{gnu} as \textsc{Gnu} given that the abbreviation
> is in uppercase. How can this be done? Thank you very much. - Leo

If you only want it in uppercase in the glossary, it would be easier
to do:
\documentclass{article}

\usepackage[colorlinks]{hyperref}
\usepackage[nomain,acronym,footnote,smallcaps]{glossaries}
\makeglossaries

\newacronym[name=GNU]{gnu}{gnu}{gnu is not unix}

\begin{document}
\Gls{gnu}

\Gls{gnu}

\gls{gnu}

\printglossaries
\end{document}

Regards
Nicola Talbot

Nicola Talbot

unread,
Nov 17, 2009, 2:50:11 PM11/17/09
to
Having thought about it a bit more, I've found another solution:

\documentclass{article}

\usepackage[colorlinks]{hyperref}
\usepackage[nomain,acronym,footnote]{glossaries}
\makeglossaries

\DeclareRobustCommand{\lcsc}[1]{\textsc{\MakeLowercase{#1}}}
\renewcommand{\acronymfont}[1]{\lcsc{#1}}
\renewcommand{\firstacronymfont}[1]{\lcsc{#1}}

\newacronym{gnu}{GNU}{gnu is not unix}

Leo

unread,
Nov 17, 2009, 5:54:29 PM11/17/09
to
On 2009-11-17 19:50 +0000, Nicola Talbot wrote:
> \DeclareRobustCommand{\lcsc}[1]{\textsc{\MakeLowercase{#1}}}
> \renewcommand{\acronymfont}[1]{\lcsc{#1}}
> \renewcommand{\firstacronymfont}[1]{\lcsc{#1}}

Many thanks for this solution.

Could you help me understand why DelcareRobustCommand is needed here? I
actually tried with something similar to this but with newcommand before
posting the question. Thank you.

- Leo

Robin Fairbairns

unread,
Nov 18, 2009, 5:44:45 AM11/18/09
to

"robust" means "works when expanded" (roughly -- of course, expansion
during the course of typesetting has to work).

anything that is to be written to a file or to a page header gets
expanded, and so needs to be robust. \DeclareRobustCommand makes a
command that automatically gets \protect inserted in front of it in
latex-y expansion contexts (typically those two).

\MakeLowercase (on its own) isn't robust, but enclosed in a command
created by \DeclareRobustCommand, it never even appears in the
file/page header because the \lcsc itself isn't expanded.

note that there are (nowadays) ways of declaring commands robustly
without using the latex mechanisms; e-tex made that possible. the
latex 3 code (and packages like etoolbox) deal with expansion that
way.
--
Robin Fairbairns, Cambridge

Leo

unread,
Nov 18, 2009, 7:02:06 AM11/18/09
to
On 2009-11-18 10:44 +0000, Robin Fairbairns wrote:
> "robust" means "works when expanded" (roughly -- of course, expansion
> during the course of typesetting has to work).
>
> anything that is to be written to a file or to a page header gets
> expanded, and so needs to be robust. \DeclareRobustCommand makes a
> command that automatically gets \protect inserted in front of it in
> latex-y expansion contexts (typically those two).
>
> \MakeLowercase (on its own) isn't robust, but enclosed in a command
> created by \DeclareRobustCommand, it never even appears in the
> file/page header because the \lcsc itself isn't expanded.
>
> note that there are (nowadays) ways of declaring commands robustly
> without using the latex mechanisms; e-tex made that possible. the
> latex 3 code (and packages like etoolbox) deal with expansion that
> way.

Many thanks, Robin.

--
Emacs uptime: 57 days, 3 hours, 16 minutes, 32 seconds

Nicola Talbot

unread,
Nov 18, 2009, 7:53:33 AM11/18/09
to

\makefirstuc can manage \makefirstuc{\lcsc{GNU}} but can't manage
\makefirstuc{\textsc{\MakeLowercase{GNU}}}. (\Gls expands the stuff in
\glsdisplay or \glsdisplayfirst before applying \makefirstuc.)

Regards
Nicola Talbot
--
Home: http://theoval.cmp.uea.ac.uk/~nlct/
LaTeX Related Information: http://theoval.cmp.uea.ac.uk/~nlct/latex/
Creating a LaTeX Minimal Example:
http://theoval.cmp.uea.ac.uk/~nlct/latex/minexample/

Leo

unread,
Nov 18, 2009, 7:06:43 PM11/18/09
to
On 2009-11-17 19:50 +0000, Nicola Talbot wrote:
> Having thought about it a bit more, I've found another solution:
>
[...]
>
> Regards
> Nicola Talbot

Based on this, I tried to use \glsentryname in captions so that
glossaries have similar look as those in text. However it does not work
as expected.

Here's an example where \glsentryname{gnu} was turned into “acronymfont
–GNU˝. Any idea how to fix this? Thank you.

\documentclass{article}
\usepackage[colorlinks]{hyperref}
\usepackage[nomain,acronym,footnote]{glossaries}
\makeglossaries

\makeatletter
\defglsdisplayfirst[\acronymtype]{%
#2#4 (\protect\glslink[\@gls@link@opts]{\@gls@link@label}
{\firstacronymfont{#1}})}%
\makeatother

\DeclareRobustCommand\lcsc[1]{\textsc{\MakeLowercase{#1}}}

\renewcommand*\acronymfont[1]{\lcsc{#1}}


\newacronym{gnu}{GNU}{gnu is not unix}
\begin{document}

\Gls{gnu}.

\Gls{gnu}.

\gls{gnu}

\begin{figure}
\centering
A figure
\caption{\glsentryname{gnu}}
\label{fig:fig1}
\end{figure}

\printglossaries
\end{document}


Leo

Nicola Talbot

unread,
Nov 19, 2009, 7:40:51 AM11/19/09
to
Leo wrote:
>
> Based on this, I tried to use \glsentryname in captions so that
> glossaries have similar look as those in text. However it does not work
> as expected.
>
> Here's an example where \glsentryname{gnu} was turned into “acronymfont
> –GNU˝. Any idea how to fix this? Thank you.

Try the package option sanitize={name=false} or use \glsentrytext
instead of \glsentryname.

Leo

unread,
Nov 19, 2009, 10:06:48 AM11/19/09
to
Hi Nicola,

On 2009-11-19 12:40 +0000, Nicola Talbot wrote:
> Leo wrote:
>>
>> Based on this, I tried to use \glsentryname in captions so that
>> glossaries have similar look as those in text. However it does not work
>> as expected.
>>
>> Here's an example where \glsentryname{gnu} was turned into “acronymfont
>> –GNU˝. Any idea how to fix this? Thank you.
>
> Try the package option sanitize={name=false}

This works and 'GNU' is typeset in \lcsc.

> or use \glsentrytext instead of \glsentryname.

This, however, typeset 'GNU' as it is. Is this expected?

>
>
> Regards
> Nicola Talbot

Thank you for your help.

Leo


--
Emacs uptime: 58 days, 6 hours, 19 minutes, 25 seconds

Nicola Talbot

unread,
Nov 19, 2009, 10:43:28 AM11/19/09
to
Leo wrote:
>> Try the package option sanitize={name=false}
>
> This works and 'GNU' is typeset in \lcsc.
>
>> or use \glsentrytext instead of \glsentryname.
>
> This, however, typeset 'GNU' as it is. Is this expected?

Yes, sorry I forgot \glsentrytext doesn't use \acronymfont.

Leo

unread,
Nov 19, 2009, 11:28:22 AM11/19/09
to
On 2009-11-19 15:43 +0000, Nicola Talbot wrote:
>> This, however, typeset 'GNU' as it is. Is this expected?
>
> Yes, sorry I forgot \glsentrytext doesn't use \acronymfont.

In this case, is there a way to ensure acronyms are typeset in the same
style? I have found \glsentryname insufficient for plural entries etc.

Thanks.

Leo

Nicola Talbot

unread,
Nov 20, 2009, 10:46:07 AM11/20/09
to

Try \protect\glspl (\protect\acrshortpl or \protect\acrlongpl or
\protect\acrfullpl as appropriate)

Leo

unread,
Nov 20, 2009, 12:52:22 PM11/20/09
to
On 2009-11-20 15:46 +0000, Nicola Talbot wrote:
>> In this case, is there a way to ensure acronyms are typeset in the
>> same style? I have found \glsentryname insufficient for plural
>> entries etc.
>
> Try \protect\glspl (\protect\acrshortpl or \protect\acrlongpl or
> \protect\acrfullpl as appropriate)

Thank you.

Leo

0 new messages