0

I'm drawing this figure

enter image description here

And specifically, in the red line X1-P I used the key shorten and I need to put in subfigure, as follows

\documentclass[11pt,letterpaper]{article}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{makeidx}
\usepackage{graphicx}
\usepackage{lmodern}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}

\usepackage{caption}
\usepackage{subfigure}

\usepackage{amsthm}

\usepackage{tikz, pgf, pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{babel, calc, through, intersections}

\title{Problema 3.4-11}
\author{}

\begin{document}
\maketitle
\begin{enumerate}
\item[\textbf{3.4-11}] Problema...

\begin{proof}
Sea $K$ la circunferencia variable y $O$ su centro (figura \ref{ej-11})...

\begin{figure}[h]
\centering
\subfigure[]{
\begin{tikzpicture}[scale=0.5, font = \small]

\node[] (O1) at (-4,0) {};
\node[] (O2) at (2,0) {};
\node[] (O) at (0,4) {};
\node[] (T) at (0,0) {};
\node[] (X1) at (-4,4) {};
\node[] (X2) at (3.2,1.6) {};
\node[] (P) at (8,0) {};

\draw[dashed, thin, gray] (0,-5) -- (0,9);
\draw[thin] (-9,0) -- (9,0);

\node (S1) at (O1) [draw, circle through = (T), cyan!75!black] {};
\node (S2) at (O2) [draw, circle through = (T), green!75!black] {};
\node (S) at (O) [draw, circle through = (T), orange] {};

\draw[red, thick, shorten >= -30pt, shorten <= -30pt] (X1) -- (P); %ERROR!

\fill (O1) circle (0.5mm);
\fill (O2) circle (0.5mm);
\fill (O) circle (0.5mm);
\fill (T) circle (0.5mm);
\fill (X1) circle (1mm);
\fill (X2) circle (1mm);
\fill[red] (P) circle (1.5mm);

\node[below left] at (P) {$P$};
\node[left] at (X1) {$X_{1}$};
\node[right] at (X2) {$X_{2}$};
\node[below] at (O1) {$O_{1}$};
\node[below] at (O2) {$O_{2}$};
\node[below] at (T) {$T$};
\node[right] at (O) {$O$};

\node[below] at (-7,-3) {$K_{1}$};
\node[below] at (3,-2) {$K_{2}$};
\node[above] at (3,7) {$K$};

\end{tikzpicture}
\label{sub:recta}
}
\caption{}
\label{ej-11}
\end{figure}
\end{proof}
\end{enumerate}
\end{document}

But this yields an error and I realized when I delete the shorten key, error disappear

What is happen?

PS. Ok, I know I can "cheat" and use auxiliary points to extend my line, but I need know the reason for this error too

I apologize for possible misspellings

pga11
  • 51
  • 3
    The subfigure package is deprecated. Please consider switching to subfig or subcaption instead. – leandriis May 25 '20 at 18:16
  • @leandriis Ok, I'm gonna try – pga11 May 25 '20 at 18:20
  • 2
    shorten by negative distances leads to paths that are not fully contained in the bounding box. That is, the length you add by supplying shorten with some negative distance will not be taken into account in the bounding box determination. –  May 25 '20 at 18:21
  • 1
    The error, however, has nothing to do with shorten. It comes from the < and > characters. Just adding >=latex yields the same error. –  May 25 '20 at 18:29
  • @Schrödinger'scat I see, doesn't it matter that I add the Tikz babel library? – pga11 May 25 '20 at 18:33
  • 1
    It suffices to say \begingroup\shorthandoff{>}\shorthandoff{<} after \centering and add \endgroup before \end{figure}. It seems to be a strange interaction between subfigure and babel. So you should do what @leandriis and will be fine, I think. –  May 25 '20 at 18:34
  • 1
    I confirm: if you use subcaption the babel library is sufficient. In your document you could use \shorthandoff{>}\shorthandoff{<}, but subcaption is probably a better choice, i.e. this issue adds to the reasons why one should no longer use subfigure. –  May 25 '20 at 18:40
  • Thank you both for your contributions! It wroks! – pga11 May 25 '20 at 18:50
  • 2
    This question seems to be related to this one, maybe a duplicate. The upshot seems to be that subcaption works without additional efforts, but subfigure and subfig do not. –  May 25 '20 at 19:03
  • I’m voting to close this question because it was solved in the comments. –  May 25 '20 at 19:50

1 Answers1

2

Since this may be helpful for others, here is a community wiki summary of the comments. The issue does not have anything to do with shorten specifically. It is because you use < and > together with

\usepackage[spanish]{babel}

Under normal circumstances one would think that

\usetikzlibrary{babel}

takes care of that. This is however not the case for your original document, which uses the subfigure package. If you keep using the package, you can add \begingroup\shorthandoff{><} after \centering, and \endgroup before \end{figure}. However, there is an arguably much better way: use the subcaption package. (This post suggests that with the subfig package the problem persists.) Then indeed the problem gets solved by loading the babel library.

\documentclass[11pt,letterpaper]{article}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{makeidx}
\usepackage{graphicx}
\usepackage{lmodern}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{amsthm}
\usepackage{tikz}
\usetikzlibrary{babel,through}

\title{Problema 3.4-11}
\author{}

\begin{document}
\maketitle
\begin{enumerate}
\item[\textbf{3.4-11}] Problema...

\begin{proof}
Sea $K$ la circunferencia variable y $O$ su centro (figura \ref{ej-11})...

\begin{tikzpicture}[scale=0.5, font = \small,>=latex]
\draw (0,0) -- (1,1);
\end{tikzpicture}

\begin{figure}[h]
\centering\begin{subfigure}[t]{0.55\linewidth}
\centering
\begin{tikzpicture}[scale=0.5, font = \small,>=latex]

\node[] (O1) at (-4,0) {};
\node[] (O2) at (2,0) {};
\node[] (O) at (0,4) {};
\node[] (T) at (0,0) {};
\node[] (X1) at (-4,4) {};
\node[] (X2) at (3.2,1.6) {};
\node[] (P) at (8,0) {};

\draw[dashed, thin, gray] (0,-5) -- (0,9);
\draw[thin] (-9,0) -- (9,0);

\node (S1) at (O1) [draw, circle through = (T), cyan!75!black] {};
\node (S2) at (O2) [draw, circle through = (T), green!75!black] {};
\node (S) at (O) [draw, circle through = (T), orange] {};

\draw[red, thick, shorten >= -30pt, shorten <= -30pt] (X1) -- (P);
%coordinate[sloped,pos=1,xshift=30pt](P') (P'); 

\fill (O1) circle [radius=0.5mm];
\fill (O2) circle [radius=0.5mm];
\fill (O) circle [radius=0.5mm];
\fill (T) circle [radius=0.5mm];
\fill (X1) circle [radius=1mm];
\fill (X2) circle [radius=1mm];
\fill[red] (P) circle [radius=1.5mm];

\node[below left] at (P) {$P$};
\node[left] at (X1) {$X_{1}$};
\node[right] at (X2) {$X_{2}$};
\node[below] at (O1) {$O_{1}$};
\node[below] at (O2) {$O_{2}$};
\node[below] at (T) {$T$};
\node[right] at (O) {$O$};

\node[below] at (-7,-3) {$K_{1}$};
\node[below] at (3,-2) {$K_{2}$};
\node[above] at (3,7) {$K$};

\end{tikzpicture}
\label{sub:recta}
\caption{A subfigure.}
\end{subfigure}
\caption{A figure.}
\label{ej-11}
\end{figure}
\end{proof}
\end{enumerate}
\end{document}

Here are some additional off-topic comments:

  1. If you shorten a path by a negative length, you make it longer, and the additional part won't be taken into account for the bounding box. In the case at hand this is not a problem.
  2. If you use the circle syntax, consider using circle[radius=...] instead of circle(...). In this case you could simplify your code by making the circles nodes. If you do that, all these \node[right]... could become labels. This would make the picture more appealing because the size of the circles will be taken into account.