我有这个 LaTeX:\caption
末尾的一行中断了编译。我该如何让它正常工作?
谢谢
\begin{center}
\begin{tikzpicture}[scale=0.2]
\tikzstyle{every node}+=[inner sep=0pt]
\draw [black] (18.1,-13.7) circle (3);
\draw (18.1,-13.7) node {$1$};
\draw [black] (18.1,-13.7) circle (2.4);
\draw [black] (38.6,-13.7) circle (3);
\draw (38.6,-13.7) node {$2$};
\draw [black] (38.6,-13.7) circle (2.4);
\draw [black] (58.6,-13.7) circle (3);
\draw (58.6,-13.7) node {$3$};
\draw [black] (58.6,-13.7) circle (2.4);
\draw [black] (10.6,-13.7) -- (15.1,-13.7);
\fill [black] (15.1,-13.7) -- (14.3,-13.2) -- (14.3,-14.2);
\draw [black] (21.1,-13.7) -- (35.6,-13.7);
\fill [black] (35.6,-13.7) -- (34.8,-13.2) -- (34.8,-14.2);
\draw (28.35,-14.2) node [below] {$\epsilon$};
\draw [black] (41.6,-13.7) -- (55.6,-13.7);
\fill [black] (55.6,-13.7) -- (54.8,-13.2) -- (54.8,-14.2);
\draw (48.6,-14.2) node [below] {$\epsilon$};
\draw [black] (57.277,-11.02) arc (234:-54:2.25);
\draw (58.6,-6.45) node [above] {$3$};
\fill [black] (59.92,-11.02) -- (60.8,-10.67) -- (59.99,-10.08);
\draw [black] (16.777,-11.02) arc (234:-54:2.25);
\draw (18.1,-6.45) node [above] {$1$};
\fill [black] (19.42,-11.02) -- (20.3,-10.67) -- (19.49,-10.08);
\draw [black] (37.277,-11.02) arc (234:-54:2.25);
\draw (38.6,-6.45) node [above] {$2$};
\fill [black] (39.92,-11.02) -- (40.8,-10.67) -- (39.99,-10.08);
\end{tikzpicture}
\caption{An NFA}
\end{center}
答案1
只需将整个东西放入图形环境中即可。请注意,它将变成浮点数,因此它可以稍微浮动 ;) 您可以使用标准参数,例如[!h]
“保持在此处”或[!t]
“尝试保持在顶部”或[!b]
“尝试保持在下方”例如\begin{figure}[!h]
对于极端措施,您可以[H]
通过加载float
包来获取参数。另一种选择是删除浮点数并使用caption
添加命令的包\captionof
。您可以将整个东西包装在 a 中minipage
以将标题与tikz
图片保持一致。浮点数可能看起来很烦人,但它们通常在较长的文档中更好,因为 LaTeX 会尝试将它们放置在美观性更好的位置(无论如何它都会尝试 - 但您可以使用参数来帮助它)。
\begin{figure}
\centering
...
\caption{}
\end{figure}
对于 tikz 绘图,我通常也将它们放入调整大小框中,以便您可以像使用一样精细地调整宽度\includeimage[width=.65\textwidth]
。
\begin{figure}
\centering
\resizebox{.65\textwidth}{!}{%
...
}%
\caption{}
\end{figure}
带标题包的示例:
\documentclass{article}
\usepackage{tikz}
\usepackage{caption}
\begin{document}
\begin{minipage}[t]{\textwidth}
\centering
\begin{tikzpicture}[scale=0.2]
\tikzstyle{every node}+=[inner sep=0pt]
\draw [black] (18.1,-13.7) circle (3);
\draw (18.1,-13.7) node {$1$};
\draw [black] (18.1,-13.7) circle (2.4);
\draw [black] (38.6,-13.7) circle (3);
\draw (38.6,-13.7) node {$2$};
\draw [black] (38.6,-13.7) circle (2.4);
\draw [black] (58.6,-13.7) circle (3);
\draw (58.6,-13.7) node {$3$};
\draw [black] (58.6,-13.7) circle (2.4);
\draw [black] (10.6,-13.7) -- (15.1,-13.7);
\fill [black] (15.1,-13.7) -- (14.3,-13.2) -- (14.3,-14.2);
\draw [black] (21.1,-13.7) -- (35.6,-13.7);
\fill [black] (35.6,-13.7) -- (34.8,-13.2) -- (34.8,-14.2);
\draw (28.35,-14.2) node [below] {$\epsilon$};
\draw [black] (41.6,-13.7) -- (55.6,-13.7);
\fill [black] (55.6,-13.7) -- (54.8,-13.2) -- (54.8,-14.2);
\draw (48.6,-14.2) node [below] {$\epsilon$};
\draw [black] (57.277,-11.02) arc (234:-54:2.25);
\draw (58.6,-6.45) node [above] {$3$};
\fill [black] (59.92,-11.02) -- (60.8,-10.67) -- (59.99,-10.08);
\draw [black] (16.777,-11.02) arc (234:-54:2.25);
\draw (18.1,-6.45) node [above] {$1$};
\fill [black] (19.42,-11.02) -- (20.3,-10.67) -- (19.49,-10.08);
\draw [black] (37.277,-11.02) arc (234:-54:2.25);
\draw (38.6,-6.45) node [above] {$2$};
\fill [black] (39.92,-11.02) -- (40.8,-10.67) -- (39.99,-10.08);
\end{tikzpicture}
\captionof{figure}{My figure.}
\end{minipage}
\end{document}