Is it possible to define an environment that strikes out all text, even in enumerated lists?
I am basically trying automate what is currently being done manually in Microsoft Word. I have a body of text and I'm told which parts are new, which parts are unchanged, and which parts have been removed since the last update.
Newly added text has to appear in bold (which is straightforward enough), but anything that has been removed needs to appear struck out. The soul
and ulem
packages get me partly there, and although they can strike out entire paragraphs, they fail when given more than one paragraph at once. I also cannot do e.g. \sout{\begin{enumerate}\item asdf\end{enumerate}}
, and if I just wrap each \item
in with \sout
, then the actual item number still appears unstruckout.
The type of text that I am trying to strike out is pretty much limited to ordinary paragraphic text and nested enumerated lists (i.e. no maths, no graphics, no figures, no headings, etc.) and will likely never be longer around half a page for each new/deleted region.
I'm not looking for anything precise or pretty, e.g. if the strikeout spans the entire width of the page just to strike out one word, that is fine. I'm also open to suggestions about alternative ways to typeset deleted text.
What I have so far is borrowed from @Werner's answer here, and I can place a horizontal rule through each line of a paragraph, but it borks enumerated lists.
\documentclass[a4paper]{article}
\usepackage{lipsum}
\newbox\strikeoutlinebox
% sorry for the messy boxes ... is there a cleaner way?
\def\strikeoutline{%
\vbox to 0pt{%
\vskip -4pt%
\hbox to 0pt{%
\vbox{\hsize\wd\strikeoutlinebox\hrule width \hsize}%
\hskip 0pt minus 1fil%
}%
\vskip 0pt plus 1fil%
}%
\box\strikeoutlinebox
}
\def\fullstrikeout{%
\setbox\strikeoutlinebox\lastbox
\ifvoid\strikeoutlinebox
\noindent\ignorespaces
\else
\unskip\unpenalty
\begingroup\fullstrikeout\space\endgroup
\strikeoutline
\fi
}
% is this bad? it's probably bad ...
\newenvironment{strikethrough}{%
\begingroup
\let\oldpar=\par
\def\par{\oldpar\fullstrikeout}%
\vbox\bgroup
}{%
\par\egroup
\let\par=\oldpar
\endgroup
}
\begin{document}
\begin{strikethrough}
\lipsum[0-3]
\end{strikethrough}
\end{document}
The above is a WIP but as you can probably tell I really have little clue what I'm doing.
\usepackage{xcolor} \newcommand\sout[1]{{\color{gray}#1}}
(redefine colour as you like; and don't loadsoul
orulem
).soul
's\so
for individual items, and you use the font I linked to for the enumerated lists. (Won't be pretty, but if you're strking out huge swaths of text, you probably are not be going for pretty.) Caveat: it would require using XeTeX or LuaTeX (but still in LaTeX format).latexdiff
.