# xymatrix spacing in lyx

I'm trying to use lyx to make an xymatrix with narrowed spacing between the rows. I found in Peter Gumm's notes http://www.mathematik.uni-marburg.de/~gumm/LyX/xypic/xypic.pdf that I could add to the preamble the following code.

 \newcommand{\xyR}[1]{%
\xydef@\xymatrixrowsep@{#1}
} % end of \xyR


and then use \xyR{} preceding the matrix entries.

For me, though, in the instant preview I get several mysterious braces preceding the matrix. And when I compile to pdf, I recieve errors "Missing number, treated as zero" and "Illegal unit of measure (pt inserted)."

Alternatively, when I use \xyR (without the braces) preceding the matrix entires, in the instant preview I see the entire matrix in a single row, and when I compile to pdf I recieve "Misplaced alignment tab character &."

Here's the code:

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[all]{xy}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.

\makeatletter
\newcommand{\xyR}[1]{%
\xydef@\xymatrixrowsep@{#1}
} % end of \xyR
\makeatother

\usepackage{babel}
\begin{document}

$\xyR\xymatrix{A & B\\ C & D\\ E & F }$
\end{document}


Any ideas? Thanks.

• Welcome to TeX.SX! Try adding \makeatletter before and \makeatother after those three lines. – egreg Jul 28 '15 at 10:03
• @egreg Doesn't change. – Alyx Jul 28 '15 at 11:40
• We need a minimal working example (MWE) (or not working as well). – egreg Jul 28 '15 at 11:44
• @egreg I edited the question with the example. (Is that what you meant?) I suppose, it is a not working one. – Alyx Jul 28 '15 at 16:25

The \xyR macro requires an argument, the desired spacing between rows.

Here's how you should use it, with also a simpler approach: if you follow \xymatrix with @R=<dimen>, the given length will be used as the space between rows; you can also use

\xymatrix@R+<dimen>
\xymatrix@R-<dimen>


that respectively add or subtract the given length from the default one. No need for \xyR, as you see.

I removed the LyX things, to make the answer more general.

\documentclass{article}

\usepackage[all]{xy}

\makeatletter
\newcommand{\xyR}[1]{%
\xydef@\xymatrixrowsep@{#1}
} % end of \xyR
\makeatother

\begin{document}

Normal $\xymatrix{A & B\\ C & D\\ E & F }$

Modified $\xyR{0pt}\xymatrix{A & B\\ C & D\\ E & F }$

Simpler $\xymatrix@R=0pt{A & B\\ C & D\\ E & F }$
\end{document}


• Much appreciated! Somehow, the first solution is still giving me problems. It displays correctly in the instant preview but does not compile "Missing \$ inserted." The second solution, which, little I know, I thought would not work in lyx because of the @, turned out to work for me. Thanks. – Alyx Jul 29 '15 at 8:52