As shown in this answer, we can strikeout text like abc $x=y$
using \st
or \sout
from the ulem and soul package, respectively. However, both approaches don't work if the text contains an equation environment (e.g. abc \begin{equation}xyz\end{equation} abc
). I know that there are options to strike out math (e.g. by \cancel
from the cancel package), but how can we strikeout both?
1 Answer
You can put the combined contents in a tcolorbox
and draw the strikeout on top using the finish
key. This answer is based on the answer to Strike a paragraph of text by Ulrike Fischer. I added the pattern fill, a custom pattern with wider lines, and a new tcolorbox
environment to make it easier to use the box multiple times. Note that it is not possible to partially strike out a line, because the box is rectangular. However, other strikeout patterns (horizontal lines for example) are possible by modifying the pattern for the \fill
command.
MWE:
\documentclass{article}
\usepackage[most]{tcolorbox}
\usetikzlibrary{patterns}
\pgfdeclarepatternformonly{mystrikeout}{\pgfqpoint{-1pt}{-1pt}}{\pgfqpoint{11pt}{11pt}}{\pgfqpoint{10pt}{10pt}}%
{
\pgfsetlinewidth{0.4pt}
\pgfpathmoveto{\pgfqpoint{0pt}{0pt}}
\pgfpathlineto{\pgfqpoint{10.1pt}{10.1pt}}
\pgfusepath{stroke}
}
\newtcolorbox{tcbstrikeout}{breakable,
enhanced jigsaw,
opacityback=0,
parbox=false,
boxrule=0mm,
top=0mm,bottom=0pt,left=0pt,right=0pt,
boxsep=0pt,
frame hidden,
finish={\fill[pattern=mystrikeout] (frame.north west) rectangle (frame.south east);}
}
\begin{document}
some text
\begin{tcbstrikeout}
\noindent abc
\begin{equation}
xyz
\end{equation}
def
\end{tcbstrikeout}
some more text
\end{document}
Result:
-
It is very nice to know the english language. For example I have not understood the question. My compliments for your answer. Sep 15, 2019 at 20:38