2

I want to increase the spacing between capital letters of acronyms inside text. Acronyms are printed by \ac, \acs, etc. commands of the glossaries package. soul package provides a nice command \caps. How can I modify glossaries to use \caps for acronyms?

Here is an example that does not work.

\documentclass{article}
\usepackage{soul} 
\usepackage[acronym,shortcuts]{glossaries} 
\makeglossaries  
\newacronym{OFDM}{OFDM}{Orthogonal Frequency Division Multiplexing} 
\let\acbak\ac
\renewcommand{\ac}[1]{\caps\acbak{#1}}
\begin{document}   
    \noindent 
    \ac{OFDM} \\
    \ac{OFDM} \\
    \caps{OFDM}
\end{document}
3

The problem is caused by \caps needing to have its argument fully expanded. Here's a solution that defines \xcaps that first expands its argument. You can then redefine \acronymfont to use \xcaps. I've used the custom style to provide the modifications.

\documentclass{article}
\usepackage{soul} 
\usepackage[acronym,shortcuts]{glossaries} 

\renewcommand{\acronymfont}[1]{\protect\xcaps{#1}}

\renewcommand*{\CustomAcronymFields}{%
  name={\noexpand\acronymfont{\the\glsshorttok}},%
  description={\the\glslongtok},%
  first={\noexpand\acrfullformat{\the\glslongtok}{\noexpand\acronymfont{\the\glsshorttok}}},%
  firstplural={\noexpand\acrfullformat
    {\the\glslongtok\noexpand\acrpluralsuffix}{\noexpand\acronymfont{\the\glsshorttok}}}%
  text={\noexpand\acronymfont{\the\glsshorttok}},%
  plural={\noexpand\acronymfont{\the\glsshorttok\noexpand\acrpluralsuffix}}%
}

\SetCustomStyle

\makeglossaries  
\newacronym{OFDM}{OFDM}{Orthogonal Frequency Division Multiplexing} 

\makeatletter
\DeclareRobustCommand{\xcaps}[1]{%
 \protected@edef\tmp{#1}%
 \expandafter\caps\expandafter{\tmp}%
}
\makeatother

\begin{document}   
\caps{OFDM}

\ac{OFDM}

\ac{OFDM}

\end{document}

Here's a simpler solution that uses the glossaries-extra extension package:

\documentclass{article}

\usepackage{soul}
\usepackage[acronym,shortcuts=ac]{glossaries-extra}

\makeglossaries

\renewcommand{\glsabbrvdefaultfont}[1]{\caps{#1}}

\setabbreviationstyle[acronym]{long-short}

\newacronym{OFDM}{OFDM}{Orthogonal Frequency Division Multiplexing}

\begin{document}
    \noindent
    \ac{OFDM} \\
    \ac{OFDM} \\
    \caps{OFDM}

\end{document}

Orthogonal Frequency Division Multiplexing (OFDM) OFDM OFDM

Use a similar method if you want to combine it with a different abbreviation style. For example:

\documentclass{article}

\usepackage{soul}
\usepackage[acronym,shortcuts=ac]{glossaries-extra}

\makeglossaries

\renewcommand{\glsabbrvscfont}[1]{\textsc{\MakeTextLowercase{\caps{#1}}}}

\setabbreviationstyle[acronym]{long-short-sc}

\newacronym{OFDM}{OFDM}{Orthogonal Frequency Division Multiplexing}

\begin{document}
    \noindent
    \ac{OFDM} \\
    \ac{OFDM} \\
    \caps{OFDM}

\end{document}

Orthogonal Frequency Division Multiplexing (ofdm) ofdm OFDM

  • thanks alot. It works fine, but smallcaps option changes \acf and first expnasion of acronyms if first={} option is used. – Aydin Mar 13 '13 at 13:40
  • @Aydin I've changed the example to use the custom acronym style. If you want a different format you can modify the custom acronym fields as required. – Nicola Talbot Mar 13 '13 at 14:06

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.