我想添加两个子图,一个在另一个之下,但下面添加的代码出现错误。我找不到为什么此代码不起作用

我想添加两个子图,一个在另一个之下,但下面添加的代码出现错误。我找不到为什么此代码不起作用
\begin{figure}[H]
\begin{center}

\begin{subfigure}
\begin{tikzpicture}
\begin{scope}[every node/.style={draw, circle, inner sep=0pt, minimum size=.15cm, fill=black}]
    \node (A) at (0,0) {};
    \node (B) at (1.5,-1.5) {};
    \node (C) at (3,0) {};
    \node (D) at (1.5,1.5) {};
    \node (E) at (1.5,3) {};
    \node (F) at (1.5,-3) {};
    \node (G) at (3,2) {};
    
    \node (H) at (4.5,1.5) {};
    \node (I) at (6,0) {};
    \node (J) at (4.5,-1.5) {};
    \node (K) at (4.5,-3) {};
    \node (L) at (4.5,3) {};
    \node (M) at (6,3) {};
    \node (N) at (6,1.5) {};
    
    \node (O) at (7.5,1.5) {};
    \node (P) at (7.5,-1.5) {};
    \node (R) at (9,1.5) {};
    
    \draw[blue,thick,dashed] (4.5,0) ellipse (5.5cm and 3.5cm);
\end{scope}

\begin{scope}
    \draw[-latex] (A) edge[bend right=15] (B);
    \draw[-latex] (B) edge[bend right=15] (C);
    \draw[-latex] (C) edge[bend right=15] (B);
    \draw[-latex] (C) edge[bend right=15] (D);
    \draw[-latex] (D) edge[bend right=15] (A);
    \draw[-latex] (E) edge (D);
    \draw[-latex] (B) edge (F);
    \draw[-latex] (C) edge[bend right=15] (G);
    \draw[-latex] (G) edge[bend right=15] (C);
    \draw[-latex] (G) edge[bend right=15] (D);
    \draw[-latex] (D) edge[bend right=15] (G);
    
    \draw[-latex] (C) edge[bend left=15] (H);
    \draw[-latex] (H) edge[bend left=15] (I);
    \draw[-latex] (I) edge[bend left=15] (J);
    \draw[-latex] (J) edge[bend left=15] (C);
    
    \draw[-latex] (H) edge[bend right=15] (L);
    \draw[-latex] (H) edge (M);
    \draw[-latex] (L) edge[bend right=15] (H);
    \draw[-latex] (M) edge[bend right=15] (L);
    \draw[-latex] (L) edge[bend right=15] (M);
    \draw[-latex] (K) edge (J);
    \draw[-latex] (M) edge (N);
    \draw[-latex] (N) edge (I);
    
    \draw[-latex] (I) edge[bend right=15] (P);
    \draw[-latex] (O) edge[bend right=15] (I);
    \draw[-latex] (M) edge (O);
    \draw[-latex] (O) edge (R);
\end{scope}

\end{tikzpicture}
\end{subfigure}

\begin{subfigure}
\begin{tikzpicture}
\begin{scope}[every node/.style={draw, circle, inner sep=0pt, minimum size=.15cm, fill=black}]
    \node (A) at (0,0) {};
    \node (B) at (1.5,-1.5) {};
    \node (C) at (3,0) {};
    \node (D) at (1.5,1.5) {};
    \node (E) at (1.5,3) {};
    \node (F) at (1.5,-3) {};
    \node (G) at (3,2) {};

    \node (H) at (4.5,1.5) {};
    \node (I) at (6,0) {};
    \node (J) at (4.5,-1.5) {};
    \node (K) at (4.5,-3) {};
    \node (L) at (4.5,3) {};
    \node (M) at (6,3) {};
    \node (N) at (6,1.5) {};

    \node (O) at (7.5,1.5) {};
    \node (P) at (7.5,-1.5) {};
    \node (R) at (9,1.5) {};

    \draw[blue,thick,dashed] (4.5,0) ellipse (5.5cm and 3.5cm);
\end{scope}

\begin{scope}
    \draw[-latex] (A) edge[bend right=15] (B);
    \draw[-latex] (B) edge[bend right=15] (C);
    \draw[-latex] (C) edge[bend right=15] (B);
    \draw[-latex] (C) edge[bend right=15] (D);
    \draw[-latex] (D) edge[bend right=15] (A);
    \draw[-latex] (E) edge (D);
    \draw[-latex] (B) edge (F);
    \draw[-latex] (C) edge[bend right=15] (G);
    \draw[-latex] (G) edge[bend right=15] (C);
    \draw[-latex] (G) edge[bend right=15] (D);
    \draw[-latex] (D) edge[bend right=15] (G);

    \draw[-latex] (C) edge[bend left=15] (H);
    \draw[-latex] (H) edge[bend left=15] (I);
    \draw[-latex] (I) edge[bend left=15] (J);
    \draw[-latex] (J) edge[bend left=15] (C);

    \draw[-latex] (H) edge[bend right=15] (L);
    \draw[-latex] (H) edge (M);
    \draw[-latex] (L) edge[bend right=15] (H);
    \draw[-latex] (M) edge[bend right=15] (L);
    \draw[-latex] (L) edge[bend right=15] (M);
    \draw[-latex] (K) edge (J);
    \draw[-latex] (M) edge (N);
    \draw[-latex] (N) edge (I);

    \draw[-latex] (I) edge[bend right=15] (P);
    \draw[-latex] (O) edge[bend right=15] (I);
    \draw[-latex] (M) edge (O);
    \draw[-latex] (O) edge (R);
\end{scope}

\end{tikzpicture}
\end{subfigure}

\caption{SCC Minimal}
\label{SCC minimal}
\end{center}
\end{figure}

答案1

您报告的错误消息表明subfigure环境未定义。由于subfigure环境未在 LaTeX 内核中定义,并且您未加载subcaptionsubfigsubfigure,因此 LaTeX 发出错误消息并不令人意外。

如果你使用该subcaption包,接下来必须用 替换 的两个\begin{subfigure}实例\begin{subfigure}{1\textwidth}

也就是说,我会subfigure完全省略这两个包装器,即,我会删除 的两个实例\begin{subfigure}和 的两个实例\end{subfigure}subfigure环境只是一个minipage恰好知道在其范围内遇到语句时该做什么的环境\caption。既然你不利用机器subfigure,为什么要不必要地弄乱你的代码呢?

相关内容