27

I'm trying to typeset a proof with Latex. When I do proofs, I like to alternate between a line of text, to explain each step, and the resulting equation. I also like to have the equations align at the =.

I can do this quite easily with begin{align} and \intertext{}. My issue, though, is that I would now like to put an equation into the \intertext. Essentially, it's a side equation which isn't directly part of the proof but is important to get from one step to the next.

Obviously, I could just abandon begin{align} and alternate between text mode and math mode, but then lines of my proof wouldn't be aligned at the =.

Is there some way that I can force \intertext to accept my equation? Otherwise, what do people generally do when they have an equation that's important to the proof but not part of the direct logic?

Thanks in advance for your advice!

4
  • 1
    Maybe try to provide a simple complete example with of your proofs (or some piece of it) so we can start with that and enhance your code ;)
    – yo'
    Mar 26, 2012 at 17:41
  • You're right, tohecz. Had I taken your advice, my error would have been immediately apparent. I only went back and further checked my coding when David said that it does in fact work. He was quite right. I'll keep this in mind when asking questions in the future. Thanks!
    – Shane
    Mar 26, 2012 at 17:56
  • @Shane It is good if you post a note as to what the error was for reference. A common mistake is to forget that \intertext is text and if you want to enclose maths within you need the $$ or \(..\). Posting your MWE post answer is also fine. Mar 26, 2012 at 18:10
  • My error was failing to close the equation within \intertext with ) (exactly as you suggested), even though I knew it had to be closed. In my actual document, I'm not surprised that happened as there were a ton of parentheses and \'s. How I repeated the same error in my simplified test (and I actually did do a test similar to David's), I'll never understand. Again, thanks to all who helped.
    – Shane
    Mar 26, 2012 at 22:48

3 Answers 3

25

This appears to just work, depending on what you want he output to look like, did you get an error message from your use of \intertext?

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{align}
1 &=2\\
\intertext{aaa}
a+b&=c+d\\
\intertext{dont't forget that
% use primitive display math here as a nested equation
% disturbs align counting
$$1111=1
\refstepcounter{equation}\eqno(\theequation)$$}
0.5&=\frac{1}{2}
\end{align}

\end{document}

The code above produces the following output: enter image description here

8
  • Hmm - that is what I'm trying to do, only with ( and ) to keep the 1=1 next to 'that'. I tried to come up with my own similar test, which didn't work. I'll play around a little more to work out where I made an error. Thanks very much!
    – Shane
    Mar 26, 2012 at 17:47
  • 1
    OK - I hate myself. It was just me getting lost in syntax and then inexplicably making the same error in the simplified test I constructed. I'm still rather prone to these errors as a novice. Thanks so much for your help!
    – Shane
    Mar 26, 2012 at 17:54
  • Can I ask why the equations are numbered ? The last one isn't numbered ... I couldn't find anything different in the code that produces numbers in one place but not in the other.
    – Saikat
    Jun 26, 2016 at 3:57
  • @user230452 excellent question!!, I fixed the code. Jun 26, 2016 at 8:53
  • 1
    yes did you try? Jun 30, 2016 at 19:38
9

You can put $<equation>$ in \intertext, as demonstrated below

enter image description here

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{align*}
    f(x) & = x^2+5x+9\\
         &= \left( x+\frac{5}{2} \right)^2-\frac{25}{4}+9
\intertext{because $\left( \frac{5}{2} \right)^2=\frac{25}{4}$}
    f(x)    & = \left( x+\frac{5}{2} \right)^2+\frac{11}{4}
\end{align*}
\end{document}
6

In answer to the question

Otherwise, what do people generally do when they have an equation that's important to the proof but not part of the direct logic?

I suggest using the extension witharrows.

\documentclass{article}
\usepackage{witharrows}
\begin{document}
\begin{DispWithArrows*}
    f(x) & = x^2+5x+9
           \Arrow{because $\left( \frac{5}{2} \right)^2=\frac{25}{4}$} \\
         & = \left( x+\frac{5}{2} \right)^2-\frac{25}{4}+9 \\
         & = \left( x+\frac{5}{2} \right)^2+\frac{11}{4}
\end{DispWithArrows*}
\end{document}

enter image description here

2
  • Is it possible to restore the font size of the text inside DispWithArrows to the normal font size of the align environment? Mar 24, 2020 at 0:35
  • 2
    @leastaction: Yes. Put \WithArrowsOptions{tikz={font={}}} in the preamble of your document. Mar 24, 2020 at 10:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .