7

enter image description here

\documentclass[preview,border=12pt,varwidth]{standalone}
\usepackage{amsmath}
\begin{document}
\abovedisplayskip=0pt\relax
\begin{gather*}
6x^2-30x+36=0\\
6(x^2-5x+6)=0\\
6(x-2)(x-3)=0\\
x-2=0 \quad \text{or} \quad x-3=0\\
x=2 \quad \text{or} \quad x=3
\end{gather*}
\end{document}

Is it a bug?

Moriambar
  • 11,466

1 Answers1

8

Putting this in gathered inside equation* removes the whitespace:

Sample output

\documentclass[preview,border=12pt,varwidth]{standalone}

\usepackage{amsmath}

\begin{document}

\abovedisplayskip=0pt\relax
\begin{equation*}
  \begin{gathered}
    6x^2-30x+36=0\\
    6(x^2-5x+6)=0\\
    6(x-2)(x-3)=0\\
    x-2=0 \quad \text{or} \quad x-3=0\\
    x=2 \quad \text{or} \quad x=3
  \end{gathered}
\end{equation*}

\end{document}

The problem comes from the varwidth package, used by standalone. Its minimal "documentation" in the header of varwidth.sty says:

% AMSmath environments have not been tried, and undoubtedly fail.

A small test document demonstrates the behaviour we are seeing above:

varwidth sample

\documentclass{article}

\usepackage{varwidth,amsmath}

\begin{document}

\fbox{\begin{varwidth}{15cm}
  \begin{equation*}
    \begin{gathered}
      6x^2-30x+36=0\\
      6(x^2-5x+6)=0
    \end{gathered}
  \end{equation*}
\end{varwidth}}

\fbox{\begin{varwidth}{15cm}
  \begin{gather*}
      6x^2-30x+36=0\\
      6(x^2-5x+6)=0
  \end{gather*}
\end{varwidth}}

\end{document}
David Carlisle
  • 757,742
Andrew Swann
  • 95,762