# Bad interaction between babel and xypic?

I'm writing an elaborate in Italian, and I'm using XY-pic to draw some diagrams. Unfortunately it seems that babel is interacting with XY-pic, making it impossible to group elements.

Here is a MWE:

\documentclass[a4paper,10pt]{article}

\usepackage[italian]{babel}

\usepackage[all]{xy}

\usepackage{amssymb}

\begin{document}

\xymatrix @R=1pt{
a & \mathbb{N} & \Rightarrow & \mathbb{N} & e & f & g \\
1 & 2 & 3 & 4 & 5 & 6 & 7
\save "1,2"."2,4"*[F.]\frm{} \restore
}

\end{document}


Which outputs:

While this is the expected output:

Which is the output I get removing the \usepackage[italian]{babel} line.

Is there anyway to use both babel and xy-pic and avoiding this interaction between the two?

• \shorthandoff{"} before the matrix. – Ulrike Fischer Sep 16 '13 at 8:52

If you don't need babel shorthands during your document, just issue

\AtBeginDocument{\shorthandoff{"}}


after loading babel. Otherwise, you have to modify the \xymatrix command so that it performs \shorthandoff{"} before starting the matrix and undoes it at the end.

\documentclass[a4paper,10pt]{article}

\usepackage[italian]{babel}
\usepackage[all]{xy}

\let\ORIGxymatrix\xymatrix
\def\xymatrix#1#{\begingroup\shorthandoff{"}\INNERxymatrix{#1}}
\def\INNERxymatrix#1#2{\ORIGxymatrix#1{#2}\endgroup}

\usepackage{amssymb}

\begin{document}
\xymatrix @R=1pt{
a & \mathbb{N} & \Rightarrow & \mathbb{N} & e & f & g \\
1 & 2 & 3 & 4 & 5 & 6 & 7
\save "1,2"."2,4"*[F.]\frm{} \restore
}

"" % this should print opening double quotes (just to see that shorthands work again

\end{document}