TransWikia.com

Space atop of align should depend on length of preceding line

TeX - LaTeX Asked on December 1, 2021

reality vs expectation

If a short line is followed by an align environment then the spacing between the aligned content and the text above it is too large (in my opinion). See the spacing above x = y_i in the example. The standard display environment [ ] seems to adjust this spacing depending on the length of the preceeding line, but align doesn’t seem to do this.

Is there a way for align to make the space atop of it depend on the length of the preceeding line (like [ ] does)?

documentclass[a4paper,10pt]{scrartcl}

usepackage{mathtools}

begin{document}
  begin{minipage}[t]{0.45textwidth}
    begin{center}
      texttt{align*}
    end{center}
     text text text text text text text text text
    begin{align*}
      x &= y_i
    shortintertext{text}
      x &= z_{i+1}
    end{align*}
    text text text text text text text text
  end{minipage}
  hfill
  begin{minipage}[t]{0.45textwidth}
    begin{center}
      texttt{textbackslash[ textbackslash]}
    end{center}
    text text text text text text text text text
    [
      x = y_i
    ]
    text
    [
      x = z_{i+1}
    ]
    text text text text text text text text
  end{minipage}
end{document}

One Answer

As explained in the comments and in the mathtools manual (section 3.1.5) this is a problem that some of the AMS environments have. The mathtools package provides the command SwapAboveDisplaySkip to fix this problem manually.

enter image description here

documentclass[a4paper,10pt]{scrartcl}

usepackage{mathtools}

begin{document}
  begin{minipage}[t]{0.45textwidth}
    begin{center}
      texttt{align*}
    end{center}
     text text text text text text text text text
    begin{align*}
      SwapAboveDisplaySkip % less space
      x &= y_i
    shortintertext{text}
      x &= z_{i+1}
    end{align*}
    text text text text text text text text
  end{minipage}
  hfill
  begin{minipage}[t]{0.45textwidth}
    begin{center}
      texttt{textbackslash[ textbackslash]}
    end{center}
    text text text text text text text text text
    [
      x = y_i
    ]
    text
    [
      x = z_{i+1}
    ]
    text text text text text text text text
  end{minipage}
end{document}

Answered by Jendrik Stelzner on December 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP