1

It seems that the cancel package does not behave well as one needs to cross out 'large' amount of text as the bar crosses the next line, and the result clearly seems unacceptable.

\documentclass{article}
\usepackage{cancel}
\usepackage{amsmath}


\begin{document}
\begin{align*}
&\cancel{1+1+1+1+1+1+1+1=0}\\
&1+1=2
\end{align*}
\end{document}

It there a way to remedy this?

  • 1
    Does \bcancel instead of \cancel help? –  Oct 03 '17 at 07:02
  • @Christian Hupfer. Thank you for your quick feedback. The problem is the same, provided the formula on the next line is long enough. Also, it does not behave well with fractions, as it adds extra vertical space (I had the impression that the slope of cancel could be automatically adapted to stay within the boundaries of a normal vertical space). – Paul-Benjamin Oct 03 '17 at 07:17
  • 1
    A better approach could be using tikz –  Oct 03 '17 at 07:19
  • I have just found that my question is a duplicate thanks of your tikz suggestion. https://tex.stackexchange.com/questions/20643/diagonal-strikeout-starting-too-low-and-ending-too-high Thank you very much. – Paul-Benjamin Oct 03 '17 at 07:26
  • 1
    That linked solution is basically the same what I tried a few moments ago. Happy TeXing –  Oct 03 '17 at 07:29
  • 1
    @ChristianHupfer I have added at https://tex.stackexchange.com/a/394341/4686 a picture based solution with offset possibilities for start and end of line. For drawing lines, no need for full-fledged tikz. –  Oct 03 '17 at 08:31

1 Answers1

3

Often, people ask for "no-package" solutions. Here it is. Well I do use package pict2e... and package color. Really need to take my memory medication now.

\documentclass{article}
\usepackage{amsmath}

\usepackage{pict2e}
\usepackage{color}

\newcommand\MyCancel[1]{%
  \begingroup
    \sbox0{#1}%
    \setlength{\unitlength}{1sp}%
    \begin{picture}(\number\wd0,\number\ht0)
      \linethickness{1.5pt}
      \put(0,0){\copy0}
      \color{red}
      \Line(0,0)(\number\wd0,\number\ht0)
    \end{picture}%
  \endgroup
}

\begin{document}
\begin{align*}
&\MyCancel{$\displaystyle1+1+1+1+1+1+1+1=0$}
\\
&1+1=2
\end{align*}
\end{document}

enter image description here

You can customize the command to get the line to possibly start and end at some offset.

  • some \m@th should be used to cancel \mathsurround setting. Telling that in case anyone uses this. Good enough for default as it is. –  Oct 03 '17 at 08:00
  • For a more complete \MyCancel with optional offsets, see https://tex.stackexchange.com/a/394341/4686. –  Oct 03 '17 at 08:32
  • Thank you very much for your answer. While this question already add a solution, I am sure this is very valuable to have alternative ones such as yours. – Paul-Benjamin Oct 03 '17 at 10:54