0

I was reading this post and encountered an error while trying to compile the following code:

\documentclass[12pt,letterpaper]{article}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{amsmath,amsfonts,amssymb}

\usepackage{tikz}
\usetikzlibrary{babel}

\usepackage{subfig}

\begin{document}
\begin{figure}
\centering
\subfloat[]{\label{fig:fig1a}
\begin{tikzpicture}[scale=0.7]
\draw (0,0) circle (2cm);
\end{tikzpicture}
}\
\subfloat[]{\label{fig:fig1b}
\begin{tikzpicture}[scale=1.4]
\draw[->,very thick] (0,0) -- (1.9,0);
\end{tikzpicture}
}
\caption{}
\label{fig:fig1}
\end{figure}
\end{document}

I have tried to edit parts of the code, and it seems that the root of the problem is that an '>' in the tikz code ends the subfloat enviroment. It's there a way to fix this?

kraDracsO
  • 104

1 Answers1

1

As @leandriis stated in his comment, your question is related to this and the solution is there. For addditional solution is to use of \shorthandoff{<>} for Spanish babel when using figure environment. That is:

\documentclass[12pt,letterpaper]{article}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{amsmath,amsfonts,amssymb}

\usepackage{tikz}
\usetikzlibrary{babel}

\usepackage{subfig}

\begin{document}
\shorthandoff{<>} %<-------------Add-------------
\begin{figure}
\centering
\subfloat[]{\label{fig:fig1a}
\begin{tikzpicture}[scale=0.7]
\draw (0,0) circle (2cm);
\end{tikzpicture}
}\
\subfloat[]{\label{fig:fig1b}
\begin{tikzpicture}[scale=1.4]
\draw[-latex,very thick] (0,0) -- (1.9,0);
\end{tikzpicture}
}
\caption{}
\label{fig:fig1}
\end{figure}
\end{document}

Output: enter image description here

  • Can you elaborate on what \shorthandoff{<>} does? – kraDracsO Mar 07 '19 at 22:05
  • 1
    The problem is that the spanish module for babel makes > and < active characters for its special management of Spanish quotations. Please look at this answer for detailed answer: https://tex.stackexchange.com/a/163955/31034 –  Mar 07 '19 at 22:53