I'm trying to highlight a text with a strikeout word by defining a new command as explained in the docs of ulem
. Unfortunately, that moves down the strikeout line a few points, which looks strange compared to non-highlighted text. How to avoid/fix this?
Here is an MWE:
\documentclass{article}
\usepackage{xcolor}
\usepackage{ulem}
\newcommand\hl{\bgroup\markoverwith{\textcolor{yellow}{\rule[-.5ex]{.1pt}{2.5ex}}}\ULon}
\begin{document}
Lorem Ipsum is simply dummy text of the printing \sout{and typesetting} industry.
\hl{Lorem Ipsum is simply dummy text of the printing \sout{and typesetting} industry.}
\end{document}
Best Answer
You could let
\hl
redefine the\sout
marco (the space in the name is important).EDIT: thanks to muzimuzhiZ for letting me know that the above became outdated.
If you're using a newer version of
ulem
starting from 2019-11-28, the\sout
macro isn't changed by the above, since it is now defined as\protected\def\sout{...}
instead. You can use the following then: