# Subfig Error while using Tikz

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?

• There seems to be a connection to \usepackage[spanish]{babel}. As an alternative to subfig you might be interested in using the subcaption package. – leandriis Mar 7 '19 at 21:04
• Use \shorthandoff{<>} after \begin{document}. – user31034 Mar 7 '19 at 21:07
• Possibly related (duplicate?): Tikz default arrow style and babel – leandriis Mar 7 '19 at 21:07
• What is the difference between subfig and subcaption? – kraDracsO Mar 7 '19 at 22:04

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}
\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:

• Can you elaborate on what \shorthandoff{<>} does? – kraDracsO Mar 7 '19 at 22:05
• 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: tex.stackexchange.com/a/163955/31034 – user31034 Mar 7 '19 at 22:53