[Tex/LaTex] Small caps acronyms with classic thesis

acronymsclassicthesissmall-caps

In an answer to my question about acronyms in section names with classic thesis I have been suggested to typeset acronyms using \spacedlowsmallcaps:

In classicthesis acronyms is typeset with space small caps, as Bringhurst recommends in his book. classicthesis has a command, \spacedlowsmallcaps, which do that. I tried to redefined the relevant command in acronym (see section 2.2 in the acronym's manual), but it did not work. I suggest you ask a new question regarding that, because then one of the gurus for certain will come up with a solution. – Sveinung

I, too, tried redefining the command with

\renewcommand*{\acsfont}[1]{\spacedlowsmallcaps{#1}}

But I got this error:

...
! Undefined control sequence.
\hyper@@link ->\let \Hy@reserved@a
                                   \relax \@ifnextchar [{\hyper@link@ }{\hyp...
l.29 ...solutions are constructed using \ac{GRASP}

Note that if I redefine it like

\renewcommand*{\acsfont}[1]{\textsc{#1}}

it shows no errors, but the text is unchanged.

I also tried to manually use \spacedlowsmallcaps when declaring the acronym

\spacedlowsmallcaps{\acs{GRASP}}

but then Latex could not find its definition (also that would not work with \ac{}, I think the proper way is to use \acsfont).

I found this answer (not related to classic thesis) where another command is suggested:

\renewcommand*{\acsfont}[1]{\textsc{\MakeLowercase{#1}}}

but it shows the same error as the \spacedlowsmallcaps one. However I thought to write acronyms directly in lowercase and that works:

% \ac{GRASP}
\ac{grasp}

...

\begin{acronym}
  % \acro{GRASP}{Greedy Randomized Adaptive Search Procedure}
  \acro{grasp}{Greedy Randomized Adaptive Search Procedure}
\end{acronym}

However it is not very convenient during writing (I will probably stick with default uppercase and run a regex substitution on the final document), is there a way to fix this using uppercase acronyms?

Here a minimal example:

\documentclass{scrreprt}

\usepackage[overload]{textcase}

\usepackage{acronym}

\usepackage[pdfspacing]{classicthesis}

% This does not work
%\renewcommand*{\acsfont}[1]{\spacedlowsmallcaps{#1}}

% This works with lowercase acronyms (as 'grasp') but not with uppercase
% ones (as 'GRASPU').
\renewcommand*{\acsfont}[1]{\textsc{#1}}

\begin{document}

Initial solutions are constructed using \ac{grasp}. \ac{grasp} generation is very fast.

Initial solutions are constructed using \ac{GRASPU}. \ac{GRASPU} generation is very fast.

\section*{Acronyms}

\begin{acronym}
  \acro{grasp}{Greedy Randomized Adaptive Search Procedure}
  \acro{GRASPU}{Greedy Randomized Adaptive Search Procedure Uppercase}
\end{acronym}

\end{document}

Best Answer

This is only a partial solution, but it might meet your needs. The problem is that \acsfont gets passed an argument that has lots of stuff including hypertext linking commands etc. Applying case-changing commands to these extra bits causes problems. My partial solution is to change the case of the text before passing the text to \ac. You could do this as follows:

\documentclass{scrreprt}
\usepackage{acronym}
\usepackage[pdfspacing]{classicthesis}

% This gives letterspaced smallcaps but does not convert case
\renewcommand*{\acsfont}[1]{\textls[80]{\textsc{#1}}}

\newcommand*{\myac}[1]{{%   % Note: two sets of braces to keep \tmp local
  \lowercase{\def\tmp{#1}}  % Defines \tmp to be a lowercase version of #1
  \ac{\tmp}}}               % Call original \ac

\begin{document}
Initial solutions are constructed using \myac{grasp}. \myac{GRASP}
generation is very fast.

\section*{Acronyms}

\begin{acronym}
  % You could also wrap \acro similarly so you could use \myacro{GRASP}
  \acro{grasp}{Greedy Randomized Adaptive Search Procedure}
\end{acronym}

\end{document}

Sample typeset with acronym package.

A couple of comments:

  1. You must wrap all of the commands you want to use. This can get a bit tedious. (I did not wrap \acro above for example.
  2. Be careful in defining the new commands to prevent extra whitespace. If you spaced out the \myac definition, you will need end-of-line comments to prevent this:

    \newcommand*{\myac}[1]{%
      {%
        \lowercase{\def\tmp{#1}}
        \ac{\tmp}%
      }%
    }
    
  3. You might like to try the glossaries package which provides builtin smallcaps support and some nice features like \Gls that capitalize the first letter. It is much more comprehensive, but also more difficult to learn. Here is a minimal example. Note: I cannot get both letter-spacing and first-letter capitalization with \Gls and friends working, but you might find it useful:

    \documentclass{scrreprt}
    
    \usepackage[smallcaps, acronym]{glossaries}
    \makeglossaries
    
    \usepackage[pdfspacing]{classicthesis}
    
    \newacronym{GRASP}{grasp}{Greedy Randomized Adaptive Search Procedure}
    
    % This gives letterspaced smallcaps but breaks capitalization \Gls{}
    \renewcommand*{\acronymfont}[1]{\textls[80]{\textsc{#1}}}
    
    \begin{document}
    Initial solutions are constructed using \gls{GRASP}. \Gls{GRASP}
    generation is very fast.
    
    \setglossarysection{section} % So you get a section.
    \printglossaries
    
    \end{document}
    

    Sample typeset with the glossaries package but no letterspacing

    This uses the nice \Gls{} feature to capitalize the first letter at the start of the second sentence, but does not letter-space the acronyms in the text. The acronym in the list of acronyms is letter-spaced because the acronyms are inserted into a description environment to which classicthesis applies letter-spacing.

    Here is the same example with the letter-spacing version of \acronymfont uncommented:

    Sample typeset with the glossaries package with letterspacing

    Notice that this breaks \Gls{} because the first-letter is now wrapped in the letter-spacing machinery. I am not yet sure how to fix this.