2

I am trying to strikeout an entire flalign block. This post shows how to strikeout an aligned block using the cancel package, but I'm not able to get it to work for the flalign environment. Any ideas how to get this to work without using tikz?

\documentclass{article}
\usepackage{amsmath}
\usepackage[makeroom]{cancel}

\begin{document}
\begin{equation*}
    \cancel{
        \begin{aligned}
        f(x) &= \sin(x) \\
        g(x) &= \cos(x)
    \end{aligned}
}
\end{equation*}
I want to strikeout this:
\begin{flalign*}
    f(x) &= \sin(x) && \\
    g(x) &= \cos(x) &&
\end{flalign*}
\end{document}
Jeff
  • 53

2 Answers2

2

You can easily define a left-aligned equation environment and then use the method with the nested aligned.

\documentclass{article}
\usepackage{amsmath}
\usepackage[makeroom]{cancel}

% https://tex.stackexchange.com/a/148854
\makeatletter

\newenvironment{flequation}
  {\@fleqntrue\begin{equation}}
  {\end{equation}\@fleqnfalse}
\newenvironment{flequation*}
  {\@fleqntrue\begin{equation*}}
  {\end{equation*}\@fleqnfalse}

\makeatother

\begin{document}

Some text
\begin{flequation*}
  \cancel{
    \begin{aligned}
      f(x) &= \sin(x) \\
      g(x) &= \cos(x)
    \end{aligned}
  }
\end{flequation*}
More text

\end{document}

enter image description here

Henri Menke
  • 109,596
  • @marmot Why? Your post is not wrong. Or are you thinking of this? – Henri Menke Apr 28 '18 at 03:56
  • No, I really think your answer is better. And no, I did not think of this. The purpose of this site is to provide users with very good solutions, and mine is clearly worse than yours, so there is no reason to keep it. –  Apr 28 '18 at 04:00
  • @marmot I ended up using the minipage solution. I don't have a good reason, but I don't care for \makeatletter.

    @HenriMenke The post on beginners accepting poor answer choices was interesting. I have been writing LaTeX for a while, but I feel that there is so much I don't know. I was looking something up in Lamport's LaTeX book a while back, and was surprised to find that I have not been using periods correctly in some situations.

    – Jeff Apr 28 '18 at 20:46
  • @Jeff I undeleted my answer but think that you should not accept it since Henri's solution is probably better for the majority of users. –  Apr 28 '18 at 23:26
  • @Jeff Do I understand this correctly, that you didn't use my answer because it has \makeatletter? If this is such a blocker for you, I can rewrite my answer without it. – Henri Menke Apr 28 '18 at 23:56
  • @HenriMenke I accepted your answer as correct. I agree with @marmot that it is probably the better way to get the strikeout. However, I try to avoid custom environments and/or using makeatletter. It's just a personal preference, and I can't really give good reason why. – Jeff Apr 29 '18 at 03:41
  • @Jeff You are right in the sense that the @ is really meant to prevent random users from overwriting important macros. But as Henri stressed this is not essential for his proposal. What I do not like about my resurrected minipage answer is that one has to specify the width. I am actually a bit less concerned about the page breaks since you most likely won't cross out some equation block that goes over more than one pages. –  Apr 29 '18 at 03:55
  • @Jeff “I try to avoid custom environments” What's the point of that other than making your life hard and littering your document with repeated markup instructions, making it unmaintainable? – Henri Menke Apr 29 '18 at 03:58
  • @marmot When I used the minipage, the value I gave for the width didn't seem to matter. Even when I gave a width that was too small, it still looked fine, but I don't know why. – Jeff Apr 29 '18 at 20:43
  • @HenriMenke I don't like custom environments/macros because I can't just copy the code and repurpose it later. I have to remember that there is a custom definition somewhere I have to copy as well. – Jeff Apr 29 '18 at 20:46
  • @Jeff That's a good observation! (Of course, if you are very picky about overfull complaints, you may not want to use it in that way.) –  Apr 30 '18 at 02:54
1

One option is to put it in a minipage and strike this out.

\documentclass{article}
\usepackage{amsmath}
\usepackage[makeroom]{cancel}

\begin{document}
\begin{equation*}
    \cancel{
        \begin{aligned}
        f(x) &= \sin(x) \\
        g(x) &= \cos(x)
    \end{aligned}
}
\end{equation*}
I want to strikeout this:\\
\xcancel{\begin{minipage}{2cm}~\\[-2\baselineskip]
\begin{flalign*}
    f(x) &= \sin(x) && \\
    g(x) &= \cos(x) &&
\end{flalign*}
\end{minipage}}
\end{document}

enter image description here

The downside of this is that you have to hard code the width of the minipage. You could cure this with a more complicated macro of by using TikZ.

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\newcommand{\tikznode}[3][]{\tikz[remember
picture,baseline=(#2.base)]{\node(#2)[inner sep=0pt,#1]{#3};}}
\begin{document}
\begin{flalign*}
    \tikznode{lt}{\strut}f(x) &= \sin(x) && \\
    g(x) &= \cos(x)\tikznode{br}{\strut} &&
\end{flalign*}
\tikz[overlay,remember picture]{\draw (lt.north) -- (br.south);}
\end{document}

enter image description here

Yet this might be an overkill.

  • I'm not a big fan of \tikzmark because unexpected things happen when you have a pagebreak in the middle of your overlay. The \cancel{\begin{aligned}...\end{aligned}} solution looks sane however. (Maybe harmonize your indentation) – Henri Menke Apr 28 '18 at 03:36
  • @HenriMenke I agree with your concern. Yet I don't understand what you precisely mean by indentation. Note that the \cancel{\begin{aligned}...\end{aligned}} is from the OP, and the user uses flalign. –  Apr 28 '18 at 03:42
  • Sorry, I realised that you just copied from OP after I posted the comment. – Henri Menke Apr 28 '18 at 03:47