4

I'm writing an article in Spanish but it seems that I have an incompatibility between babel commands and xy-pic. There is an older topic on the same issue but the solution there is not working for me (Bad interaction between babel and xy pic).

This is a short version of the problem:

\documentclass[12pt,letter,openright,final]{article}

\usepackage[utf8]{inputenc}
\usepackage[english,spanish]{babel}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage[all]{xy}

\begin{document}

\begin{abstract}
Tuki tuki

\textit{Palabras clave}: tuki, tuki, tuki.
\end{abstract}

\begin{otherlanguage}{english} % THIS IS WHERE THE PROBLEM IS
\begin{abstract}
Tookey Tookey

\textit{Keywords}: tookey, tookey, tookey.
\end{abstract}
\end{otherlanguage}


\begin{section}{Introducción}

Blah

\end{section}

\begin{section}{Sección}

Blah

$$\xymatrix@=1cm{
A \ar@{<->}[r]^{\oplus} \ar@{<->}[dr] & E\ar@{->}[d]^{\rhd}\\
I \ar@{<-}[u]^{\rhd} \ar@{<->}[ru]^{\hspace{3pt}\otimes} & O\ar@{<->}[l]^{\ominus}
}$$

blah

\end{section}

\end{document}

When I try to compile it (MiKTeX, using pdfLaTeX) I get this error:

! Xy-pic error: illegal <arrow>: macro:->\es@use@shorthand < not valid. \xyerror@ ...#2}\fi \errmessage {Xy-pic error: #1}
                                                 } l.54 }
     $$

There is a topic on this site (xypic produces error when I try to use any arrow style) where this error is discussed, but the solution there is useless for me, as babel is already loaded before xy. (I tried changing them anyway but I still got the problem.)

If I remove the \otherlanguage environment, I got no problem with xymatrix.

It gets the same with \selectlanguage{english} (...) \selectlanguage{spanish}.

BUT! If I put the \otherlanguage environment inside the \abstract environment, it works as it should. The problem is that I need the header of the abstract be "abstract" and not "resumen", for it is the English one (the Spanish one is before, as usual).

I was looking inside babel and xy-pic documentation but I still can't figure it out why this is happening.

6

You can use option es-noquoting if you do not need << and >> as replacement for \begin{quoting} and \end{quoting}. Note that you can still use the synonyms "` and "'.

\documentclass[12pt]{article}
\usepackage{amssymb}
\usepackage[utf8]{inputenc}
\usepackage[english,spanish
  ,es-noquoting% <- added
]{babel}

\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage[all]{xy}

\begin{document}
\begin{otherlanguage}{english}
\begin{abstract}
Tookey Tookey
\end{abstract}
\end{otherlanguage}

\section{Introducción}
Blah
\section{Sección}
Blah
\[\xymatrix@=1cm{
A \ar@{<->}[r]^{\oplus} \ar@{<->}[dr] & E\ar@{->}[d]^{\rhd}\\
I \ar@{<-}[u]^{\rhd} \ar@{<->}[ru]^{\hspace{3pt}\otimes} & O\ar@{<->}[l]^{\ominus}
}\]

"`blah"'
\end{document}

Or you can use \deactivatequoting:

\documentclass[12pt]{article}
\usepackage{amssymb}
\usepackage[utf8]{inputenc}
\usepackage[english,spanish]{babel}
\deactivatequoting% <- added
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage[all]{xy}

\begin{document}
\begin{otherlanguage}{english}
\begin{abstract}
Tookey Tookey
\end{abstract}
\end{otherlanguage}

\section{Introducción}
Blah
\section{Sección}
Blah
\[\xymatrix@=1cm{
A \ar@{<->}[r]^{\oplus} \ar@{<->}[dr] & E\ar@{->}[d]^{\rhd}\\
I \ar@{<-}[u]^{\rhd} \ar@{<->}[ru]^{\hspace{3pt}\otimes} & O\ar@{<->}[l]^{\ominus}
}\]

"`blah"'
\end{document}
5

Spanish babel makes a few characters active and usable as commands make the source code prettier (they are ', ", ~, <, >). The last two of them conflict with xy-pic. You has to deactivate them prior of using \xymatrix@.

\documentclass[12pt,letter,openright,final]{article}

\usepackage{amssymb}
\usepackage[utf8]{inputenc}
\usepackage[english,spanish]{babel}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage[all]{xy}

\begin{document}

\begin{abstract}
Tuki tuki

\textit{Palabras clave}: tuki, tuki, tuki.
\end{abstract}

\begin{otherlanguage}{english} % THIS IS WHERE THE PROBLEM IS
\begin{abstract}
Tookey Tookey

\textit{Keywords}: tookey, tookey, tookey.
\end{abstract}
\end{otherlanguage}


\begin{section}{Introducción}

Blah

\end{section}

\begin{section}{Sección}

Blah
\spanishdeactivate{<>}
\[\xymatrix@=1cm{
A \ar@{<->}[r]^{\oplus} \ar@{<->}[dr] & E\ar@{->}[d]^{\rhd}\\
I \ar@{<-}[u]^{\rhd} \ar@{<->}[ru]^{\hspace{3pt}\otimes} & O\ar@{<->}[l]^{\ominus}
}\]

blah

\end{section}

\end{document}

I've also added \usepackage{amssymb} for the \rhd command.

  • Both this solution and the precedent were useful. Thanks! – Inti Målai May 28 '17 at 3:47

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.