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
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
\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}
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
"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
Many thanks, Robin.
--
Emacs uptime: 57 days, 3 hours, 16 minutes, 32 seconds
\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/
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
Try the package option sanitize={name=false} or use \glsentrytext
instead of \glsentryname.
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
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
Try \protect\glspl (\protect\acrshortpl or \protect\acrlongpl or
\protect\acrfullpl as appropriate)
Thank you.
Leo