I have been slowly learning LaTeX over the past few years. I have been mostly successful in these efforts.
Recently, I stumbled across a problem, I know is probably quite simple to fix, but it has me stumped. I figure, it has to do with macro expansion. These macro expansion issues are undoubtedly one of my big remaining hangups.
Looking for any input on the problem below. I tried doing various combinations of \expandafter
, \edef
, etc., but I was obviously just randomly stumbling around.
I have seen some related questions, but they each appear to be trying to do something slightly different and the suggestions do not appear to help me in my situation.
MWE provided:
\documentclass[10pt]{article}
\usepackage{soul}
\def\qwerty{happy new year}
\begin{document}
\ul{happy new year}
\ul{\qwerty}
\end{document}
And the error:
! Package soul Error: Reconstruction failed.
See the soul package documentation for explanation.
Type H <return> for immediate help.
...
l.10 \ul{\qwerty}
I know the solution is simple. Anything to point me in the direction, which will contribute to my understanding of the problem and solution, would be greatly appreciated.
soul
doesn't expand tokens. Try\ul{\mbox{\qwerty}}
. – Phelype Oleinik Jun 21 '19 at 18:37soul
has compared to\underline
or similar: disabling hyphenation and line breaks. Instead, if you know that the macro you're using is fully expandable, you can use the following (if you have an up to date LaTeX installation):\expandafter\ul\expandafter{\expanded{<macro>}}
(which is the case for the shown definition of\qwerty
). – Skillmon Jun 21 '19 at 18:39