I used soul
to do the strikethrough, but had to define a displayst
command to do strikethrough in display math mode. (soul
commands only work with math as in \st{$abc$}
. . . ) I also used the solution from Why is it that coloring in soul in beamer is not visible to make the color work. Use \setul{⟨underline depth⟩}{⟨underline thickness⟩}
to change thickness of underline/strikethrough in soul
.–
\documentclass[12pt]{beamer}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{lmodern}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{color,soul}
\makeatletter
\newcommand\SoulColor{%
\let\set@color\beamerorig@set@color
\let\reset@color\beamerorig@reset@color}
\makeatother
\setstcolor{red}
%\setul{}{1pt} Use this to change weight of underline/strikethrough
\newcommand{\displayst}[1]{\textrm{\SoulColor\st{$\displaystyle#1$}}}
\begin{document}
\begin{frame}
\begin{align*}
P = \{ & \displayst{S\rightarrow X_{1,4,2}}\\
& X_{1,4,1}\rightarrow X_{1,1,1}X_{2,3,1},\\
& X_{1,4,1}\rightarrow X_{1,1,1}X_{2,3,1}\}
\end{align*}
\end{frame}
\end{document}
Result:
Edit
I guess making this work nicely with soul
required fixing a few things. The original solution I posted strikes behind the text, instead of on top of it, but this was solved in Strikeout in different color appears behind letters, not on top of them
\documentclass[12pt]{beamer}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{lmodern}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{xparse,xcolor,soul}
%% First define strikethrough command that strikes on top of letters, not behind them
\makeatletter
\NewDocumentCommand{\sttwo}{O{red}O{black}+m}
{%
\begingroup
\setulcolor{#1}%
\setul{-.5ex}{1pt}% <---- sets the undline/strikeout weight to 1pt
\def\SOUL@uleverysyllable{%
\rlap{%
\color{#2}\the\SOUL@syllable
\SOUL@setkern\SOUL@charkern}%
\SOUL@ulunderline{%
\phantom{\the\SOUL@syllable}}%
}%
\ul{#3}%
\endgroup
}
\makeatother
% Now make soul colors work with beamer
\makeatletter
\newcommand\SoulColor{%
\let\set@color\beamerorig@set@color
\let\reset@color\beamerorig@reset@color}
\makeatother
%Now make a version of strikethrough that works with display math
\newcommand{\displayst}[1]{\textrm{\SoulColor\sttwo{$\displaystyle#1$}}}
\begin{document}
\begin{frame}
\begin{align*}
P = \{ & \displayst{S\rightarrow X_{1,4,2}}\\
& X_{1,4,1}\rightarrow X_{1,1,1}X_{2,3,1},\\
& X_{1,4,1}\rightarrow X_{1,1,1}X_{2,3,1}\}
\end{align*}
\end{frame}
\end{document}
Result:
This just puts a paragraph parsing wrapper around \xout
and \sout
, given as \xoutpars
and \soutpars
.
However, this will not address things like math, etc.
\documentclass{article}
\usepackage{ulem,lipsum}
\newcommand\xoutpars[1]{\let\helpcmd\xout\parhelp#1\par\relax\relax}
\newcommand\soutpars[1]{\let\helpcmd\sout\parhelp#1\par\relax\relax}
\long\def\parhelp#1\par#2\relax{%
\helpcmd{#1}\ifx\relax#2\else\par\parhelp#2\relax\fi%
}
\begin{document}
\xout{Lorum ipsum dola blah blah blah.}
\sout{Lorum ipsum dola blah blah blah.}
Now we start. \xoutpars{This is a test
...of multiple paragraphs.
And now a third.}
Now we start. \soutpars{This is a test
...of multiple paragraphs.
And now a third.}
\end{document}
Best Answer
This uses a variation on my
censor
package to accomplish the strikeout, since the\xblackout
macro of that package can work across paragraph boundaries (but not across math, which the OP clarified is not needed).To make the
\xblackout
macro operate as an environment, I used theenviron
packages feature of\BODY
. Even so, I had to go through an intermediate macro\soutrefunexp
in order to expand\BODY
once, to make it digestible to\xblackout
.Replacing
\xblackout
with\blackout
produces the following slightly different result: