我正在画这个图
具体来说,在红线中X1-P
我使用了密钥shorten
,我需要输入subfigure
,如下所示
\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}
但这会产生一个错误,我意识到当我删除缩短键时,错误就会消失
发生什麼事了?
PS. 好吧,我知道我可以“作弊”并使用辅助点来延长我的线,但我也需要知道这个错误的原因
我对可能的拼写错误表示歉意
答案1
由于这可能对其他人有帮助,这里是社区 wiki 对评论的总结。这个问题与shorten 无关。这是因为你同时使用<
了>
\usepackage[spanish]{babel}
在正常情况下,人们会认为
\usetikzlibrary{babel}
处理了这个问题。但是对于使用该包的原始文档来说情况并非如此subfigure
。如果继续使用该包,则可以添加\begingroup\shorthandoff{><}
after\centering
和\endgroup
before \end{figure}
。但是,有一种可以说更好的方法:使用subcaption
包。 (这个帖子表明使用该subfig
软件包问题仍然存在。)然后,通过加载库,问题确实得到了解决babel
。
\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}
以下是一些额外的题外评论:
- 如果将路径缩短为负长度,则会使其变长,并且额外的部分将不会被考虑在边界框中。在本例中这不是问题。
- 如果您使用
circle
语法,请考虑使用circle[radius=...]
而不是circle(...)
。在这种情况下,您可以通过将圆圈设为节点来简化代码。如果这样做,所有这些\node[right]...
都可以成为标签。这将使图片更具吸引力,因为圆圈的大小将被考虑在内。