1

Compiling the following file

\documentclass{article}
% \usepackage{xcolor} % this guy does the highlighing work
\usepackage{soul}
\begin{document}
\hl{cf.\ ??}
\end{document}

with pdflatex produces the error

! Package soul Error: Reconstruction failed.

See the soul package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.5 \hl{cf.\ ??}

? Q

(In the above, xcolor is not loaded for the purpose of constructing a minimal non-compiling example.)

Of course, workarounds exist, such as replacing .\with .\@, or putting the sucker into an \mbox. Still, I wonder whether one could have a better automatic solution in first place. Perhaps, a better highlighting package?

  • 1
    General speaking: Underlining is actually not used in professional typesetting. If you want to highlight (emphase) something use \emph{..} or, for stronger emphasis \textbf{..} instead. – Martin Scharrer Apr 3 '18 at 14:45
  • @MartinScharrer \hl doesn't really underline, but it uses a background color when color or xcolor is loaded. – egreg Apr 3 '18 at 14:51
  • @egreg: Good to know. I just ran the MWE and there it underlines as no color package is loaded. – Martin Scharrer Apr 3 '18 at 14:57
  • @MartinScharrer It does not compile for me regardless of whether xcolor is loaded or not. If you change "cf.\ ??" to something else, the compilation works, and then you can think of whether you'd like underlining (without xcolor) or highlighting (with xcolor). – user159824 Apr 3 '18 at 15:02
  • @VasiliPupkin: Well, I changed \ to \@ first as you wrote. I just wanted to see what \hl does without studying the manual. – Martin Scharrer Apr 3 '18 at 15:19
1

Well, \hl{cf.\ x} eats up the x.

\documentclass{article}
\usepackage{soul,xcolor}
\begin{document}

\hl{cf.\ x}

\hl{cf.\@ ??}

cf.\@ ??

\end{document}

Using \@ is the correct way to cope with the spacing.

enter image description here

  • Thank you, but lots of people use .\ without ill effects. In fact, it is even mentioned in TeXbook by D. E. Knuth in Chapter 12: Glue. – user159824 Apr 3 '18 at 15:11
  • @VasiliPupkin The TeXbook doesn't mention soul, does it? ;-) There are several things that are legal in plain TeX, but deprecated with LaTeX. – egreg Apr 3 '18 at 15:40
  • @Does .\@ also work after \makeatletter? – user159824 Apr 14 '18 at 9:37
  • @VasiliPupkin Yes, but a space after it would be ignored. – egreg Apr 14 '18 at 9:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy