1

This question already has an answer here:

When you use the \intertext in the \align* environment with the amsmath package, it has a small vertical space between the displayed text and equation even though it is still coded on the same line as the equation.

In a regular line of code, you can type \intertext{text} (generic equation) on the one line. Yet, when it is compiled, it visual output shows a small vertical space between the text and the equation that I did not add manually.

I am using \intertext because it is left-aligned and I don't want the equation itself to be left-aligned, just the text, but it should also be on the same displayed line as the \intertext.

marked as duplicate by David Carlisle spacing Jan 6 at 10:35

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 3
    Please, please, please show us a short compilable code resulting in your issue. Please learn from older comments, I asked you to do so in your last question too ... Simply help us to help you! – Mensch Jan 6 at 2:28
  • 2
    @user14554: It's not clear what you mean by \intertext being on the same line as the math display. Are you talking about your code, or the output? If you just want some textual display, use \text, not \intertext. – Werner Jan 6 at 2:43
  • 2
    @user14554: Stick to the script. You have a problem and we're here to solve it. Can you answer my question? – Werner Jan 6 at 2:48
  • 2
    @user14554: Okay, so you use \intertext and it inserts a (vertical) gap. That's what it's meant to do. If that's not what you want, then what do you want? Do you just want to insert text? Then use \text as I suggested... – Werner Jan 6 at 2:50
  • 1
    @user14554: You want non-left-aligned \intertext it seems. \text doesn't centre its contents. – Werner Jan 6 at 2:53
2

If \intertext inserts too much vertical space between the equation components, then consider using \shortintertext from mathtools:

enter image description here

\documentclass{article}

\usepackage{mathtools}

\begin{document}

\begin{align*}
           f(x) &= ax^2 + bx + c \\
  ax^2 + bx + c &= f(x)          \\
\intertext{here is some \texttt{intertext}}
           f(x) &= ax^2 + bx + c \\
  ax^2 + bx + c &= f(x)          \\
\shortintertext{here is some \texttt{short intertext}}
           f(x) &= ax^2 + bx + c \\
  ax^2 + bx + c &= f(x)          \\[-.8\normalbaselineskip]
\intertext{here is some \texttt{intertext}} \\[-2.2\normalbaselineskip]
           f(x) &= ax^2 + bx + c \\
  ax^2 + bx + c &= f(x)
\end{align*}  

\end{document}

If you really don't like the space around either, you can use the optional argument of \\[<len>] to insert negative vertical space and shrink the gap to suit your needs (the last option in the above code).

  • It seems shortintertext has the same problem of creating a vertical gap. I tried copying and pasting \\[<len>] inside the align* environment in different locations but all I got was the error "treated as zero" or "misplaced tab character". – user14554 Jan 6 at 3:06
  • 1
    @user14554: You need a length where I have <len>; something like \\[-20pt]. – Werner Jan 6 at 3:08
  • Okay then, \\[<length>pt] seems to do the trick, but is there anything that specifies exactly how big the \intertext or \shortintertext vertical gap is to completely get rid of it without adding too much space? All I want is to get rid of the gap that \intertext causes, going over that would likely cause errors down the document. – user14554 Jan 6 at 3:11
  • @user14554: \intertext inserts a gap of \belowdisplayskip above it and \abovedisplayskip below it. \shortintertext uses a default 3pt above and below. – Werner Jan 6 at 3:15
  • 3pt is much to small to close the gap, but -30 in the \\[...] seems aligned. Is -30pt what you meant? It's a good guess but the real spacing could be 35pt or 29pt, the ams manual doesn't seem to specify. – user14554 Jan 6 at 3:37

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