5

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:

enter image description here

While this is the expected output:

enter image description here

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?

Moriambar
  • 11,466
Bakuriu
  • 2,218

1 Answers1

5

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}

enter image description here

David Carlisle
  • 757,742
egreg
  • 1,121,712