3

I am using the command \sout{some text} to strike out a word or a sentence; However, I wanted to know if it is possible to strike out a group of text without having to use the braces { and }.

Something similar to what {\color{red} some text} is to \textcolor{red}{some text}, or something like \begin{sout} and \end{sout} (this doesn't work!)

2
  • Must it also handle text style and/or display style math automatically? Mar 8, 2016 at 16:17
  • Hi Steven! Thank you for your answer. I do not need to strike out maths, but I need the keep paragraphs/fonts intact
    – VieuxSinge
    Mar 8, 2016 at 16:22

1 Answer 1

4

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 the environ 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.

\documentclass{article}
\usepackage{environ,censor,calc}
\NewEnviron{mysout}
 {\soutrefunexp{\BODY}}
%%%%%%%%%%%
\censorruleheight=.1ex %THICKNESS OF CENSOR RULE
\newlength\nextcharwidth
\makeatletter
\renewcommand\@cenword[1]{%
  \setlength{\nextcharwidth}{\widthof{#1}}%
  \censorrule{\nextcharwidth}%
  \kern -\nextcharwidth%
  #1}
\makeatother
\newcommand\soutref[1]{\censorruledepth=.55ex\xblackout{#1}}
\newcommand\soutrefunexp[1]{\expandafter\soutref\expandafter{#1}}
%%%%%%%%%%%
\begin{document}
What is this?

Another paragraph.

\begin{mysout}
What is this?

Another paragraph.
\end{mysout}

What is this?

Another paragraph.
\end{document}

enter image description here

Replacing \xblackout with \blackout produces the following slightly different result:

enter image description here

0

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.