3

Using pdflatex Version 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian) and standalone 2015/07/15 v1.2

The following fails with "! Missing $ inserted.". Replacing standalone with article works as expected.

\documentclass{standalone}
\usepackage[all]{xy}

\begin{document}
$$
\vcenter{
\xymatrix{
A \ar[d] \ar[r] & B \ar[d] \\
C \ar[r] & D
}
}
$$
\end{document}
  • Don't use vcenter, neither $$. Use only $\xymatrix{A \ar[d] \ar[r] & B \ar[d] \\C \ar[r] & D}$. – Sigur Feb 28 '18 at 13:30
  • Standalone supposed to not have a layout... so "double $" means something without sence for this documentclass. Use single $ – koleygr Feb 28 '18 at 13:32
3

Don't use vcenter, neither $$...$$.

Use only $\xymatrix{A \ar[d] \ar[r] & B \ar[d] \\C \ar[r] & D}$.

\documentclass{standalone}
\usepackage[all]{xy}

\begin{document}
$\xymatrix{
A \ar[d] \ar[r] & B \ar[d] \\
C \ar[r] & D
}$
\end{document}

enter image description here

  • It would be very hard to get rid of \vcenter, I don't have much control over the content (otherwise I wouldn't have xymatrix in 2018...). Fortunately replacing $$ by $ seems to be enough. – Patrick Massot Feb 28 '18 at 14:07
2

The default of standalone is to typeset a horizontal box (\hbox, precisely). Hence the text is in “restricted horizontal mode”, where $$ just means an empty math formula. Hence \vcenter is scanned in horizontal mode rather than math mode and an error ensues.

Of course \vcenter does nothing at all in standalone, nor math mode is necessary, because \xymatrix is perfectly legal also in text mode.

\documentclass{standalone}
\usepackage[all,cmtip]{xy}

\begin{document}
\xymatrix{
  A \ar[d] \ar[r] & B \ar[d] \\
  C \ar[r] & D
}
\end{document}

By the way, \vcenter is a wild beast and using it requires care. You're lucky enough that \xymatrix encloses the material in a \hbox, otherwise you'd be in trouble (try $\vcenter{a}$ in a normal document).

In order to vertically center an \xymatrix, it's better to use

\begin{gathered}
\xymatrix{...}
\end{gathered}

which requires amsmath.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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