2

I'm finding that if I use an acro acronym inside a soul strikeout command, I get errors about the acronym not being defined. Here is my Minimal Working Example:

\documentclass{article}
\usepackage{acro} % Handling of acronyms
\usepackage{soul} % Strikeout font
%\soulfont{\ac}{1} % Protect's \ac command from soul
\DeclareAcronym{abc}{ short = ABC, long =AbBraCadabra }
\begin{document}

Try strikeout \st{abc}

Try acronym \ac{abc}

% This causes error about undefined acronym '{abc}'
Try strikeout acronym \st{\ac{abc}}

\end{document}

The commented-out \soulfont command is an attempt protect the \ac command, as per the soul packcage documentation (section "Adding font commands"). It causes the following error

! TeX capacity exceeded, sorry [input stack size=5000].
\SOUL@do #1->\SOUL@scan 
                        #1\SOUL@stop 

Is there any way around this without abandoning the acro package?

IdleCustard
  • 1,194
user36800
  • 875

2 Answers2

2

The following example modifies egreg's answer and puts \ac inside a box (prevents line breaks) and uses the box inside of \st. This also works for the first usage of acronyms:

\documentclass{article}

\usepackage{acro} % Handling of acronyms
\usepackage{soul} % Strikeout font

\DeclareAcronym{abc}{ short = ABC, long =AbBraCadabra }

\newsavebox\tmpbox

\begin{document}

Try strikeout \st{abc}

Try strikeout acronym \sbox\tmpbox{\ac{abc}}\st{foo {\usebox\tmpbox} bar}

\end{document}

Result

Heiko Oberdiek
  • 271,626
1

You can brace the usage of \ac inside \st. However, it will not work for not yet used acronyms.

\documentclass{article}

\usepackage{acro} % Handling of acronyms
\usepackage{soul} % Strikeout font

\DeclareAcronym{abc}{ short = ABC, long =AbBraCadabra }

\begin{document}

Try strikeout \st{abc}

Try acronym \ac{abc}

Try strikeout acronym \st{abc {\ac{abc}} abc}

\end{document}

enter image description here

egreg
  • 1,121,712