不听话的图表和恢复标题枚举的方法

不听话的图表和恢复标题枚举的方法

这个问题底部的代码产生图像。将此图像放大到相关位置将显示以下内容。

飞涨

如您所见,最后三个图表已损坏(在 (vi) 和 (vii) 中,2 低于我想要的值,而 (viii) 应该是立方体的顶点)。我尝试通过显式坐标创建图表,但结果相同,无法正常工作。

另一个问题是,这是一份较大文档的一部分,我认为由于空间不足,图表被移到了另一页。我猜想这是因为图表都在 \begin{figure} \end{figure} 内,但我需要它们都位于 \begin{figure} \end{figure} 内,以便获得适当的标题。

我该如何解决这两个问题?

\documentclass{article}
\usepackage{tikz}
\usepackage{subcaption}
\renewcommand\thesubfigure{\roman{subfigure})}
\DeclareCaptionLabelFormat{paren}{(#2}
\captionsetup[subfigure]{labelformat=paren}
\usetikzlibrary{positioning}
\tikzset{mynode/.style={draw,circle,inner sep=2pt,outer sep=0pt}}

\begin{document}
 \begin{figure}[htb]
  \centering
  \subcaptionbox{}{%
   \begin{tikzpicture}

    \node [mynode,label=above:30] (30) at (0,0) {};
    \node [mynode,below left  = of 30,label=left:2] (2)  {};
    \node [mynode,below right = of 30,label=right:5] (5) {};
    \node [mynode, below = of 30, label=right:3] (3) {};
    \node [mynode,below  = of 3,label=below:1] (1) {};

    \draw (30) -- (2) 
          (30) -- (5)
          (30) -- (3) 
           (2) -- (1)
           (3) -- (1) 
           (5) -- (1);

   \end{tikzpicture}
  }
  \hfil
  \subcaptionbox{}{%
   \begin{tikzpicture}

    \node [mynode,label=above:12] (12) at (0,0) {};
    \node [mynode,below left  = of 12,label=left:4] (4)  {};
    \node [mynode,below right = of 30,label=right:3] (3) {};
    \node [mynode,below left  = of 4,label=left:2] (2)  {};
    \node [below = of 12] (a) {};
    \node[below = of a] (b) {};
    \node[mynode, below of = b, label=right:1] (1) {};

    \draw (12) -- (4)
          (12) -- (3)
           (4) -- (2)
           (2) -- (1)
           (3) -- (1);

   \end{tikzpicture}
  }

  \subcaptionbox{}{
   \begin{tikzpicture}

    \node [mynode,label=above:10] (10) at (0,0) {};
    \node [mynode,below left  = of 10,label=left:2] (2)  {};
    \node [mynode,below right = of 10,label=right:5] (5) {};
    \node [mynode,below right  = of 2,label=below:1] (1)  {};

    \draw (10) -- (2)
          (10) -- (5)
           (5) -- (1)
           (2) -- (1);                   
   \end{tikzpicture}
  }
  \hfil
  \subcaptionbox{}{
   \begin{tikzpicture}                   
    \node [mynode,label=right:16] (16) at (0,0) {};
    \node [mynode, below of = 16, label=right:8] (8) {};
    \node [mynode, below of = 8, label=right:4](4) {};
    \node [mynode, below of = 4, label=right:2] (2){};
    \node [mynode, below of =2, label=right:1](1){};

    \draw (16) -- (8)
           (8) -- (4)
           (4) -- (2)
           (2) -- (1);                   
   \end{tikzpicture}
  }

  \subcaptionbox{}{
   \begin{tikzpicture}                   
    \node [mynode,label=right:18] (18) at (0,0) {};
    \node [mynode, left of = 18, label=left:12] (12) {};
    \node [mynode, below of = 18, label=right:3](3) {};
    \node [mynode, below of = 12, label=left:2] (2){};

    \draw (18) -- (2)
          (18) -- (3)
          (12) -- (2)
          (12) -- (3);                   
    \end{tikzpicture}
  }
  \hfil
  \subcaptionbox{}{
   \begin{tikzpicture}

    \node [mynode,label=above:12] (12) at (0,0) {};
    \node [mynode,below left  = of 12,label=left:4] (4)  {};
    \node [below of = 12] (a) {};
    \node [mynode,below right = of 12,label=right:6] (6) {};
    \node [mynode,below = of 4,label=left:2] (2)  {};
    \node [below of = a] (b) {};
    \node [mynode, below of = 6, label=right:3] (3) {};
    \node [mynode, below of = b, label=below:1](1) {};

    \draw ;                   
   \end{tikzpicture}
  }

  \subcaptionbox{}{
   \begin{tikzpicture}

       \node [mynode,label=above:12] (12) at (0,0) {};
       \node [mynode,below left  = of 12,label=left:4] (4)  {};
       \node [below of = 12] (a) {};
       \node [mynode,below right = of 12,label=right:6] (6) {};
       \node [mynode,below = of 4,label=left:2] (2)  {};
       \node [below of = a] (b) {};
       \node [mynode, below of = 6, label=right:3] (3) {};
       \node [mynode, below of = b, label=below:1](1) {};

       \draw ;                   
      \end{tikzpicture}
  }
  \hfil
  \subcaptionbox{}{
   \begin{tikzpicture}

    \node [mynode,label=above:30] (30) at (0,0) {};
    \node [mynode,below left  = of 30,label=left:6] (6)  {};
    \node [mynode, below = of 30, label=right:10] (10) {};
    \node [mynode,below right = of 30,label=right:15] (15) {};
    \node [mynode,below = of 6,label=left:2] (2)  {};
    \node [mynode, below = of 10, label=right:3] (5) {};
    \node[mynode, below = of 15, label=right:5] (5) {};
    \node[mynode, below of = 3, label=below:1] (1) {};

    \draw ;                   
   \end{tikzpicture}
  }
 \end{figure}
\end{document}

答案1

您不应混淆below = of(不带positioning库)和below = of(带positioning库)。最好始终使用positioning库及其below/above/right/left = of语法(即of应位于之后=)。有关详细信息,请参阅pgfmanual(17.5.3,第 230 页)texdoc.net 的搜索窗口texdoc pgfmanual或者在你的终端中运行。

此外,如果您的图形包含许多子图形,无法容纳在一页中,您可以加载caption包并使用其\ContinuedFloat宏。您必须手动为所有进入下一页的图形添加带有 (cont.) 的标题,就像我在以下代码中所做的那样。

\documentclass{article}
\usepackage{lipsum,showframe}
\usepackage{tikz}
\usepackage{caption}
\usepackage{subcaption}
\renewcommand\thesubfigure{\roman{subfigure})}
\DeclareCaptionLabelFormat{paren}{(#2}
\captionsetup[subfigure]{labelformat=paren}
\usetikzlibrary{positioning}
\tikzset{mynode/.style={draw,circle,inner sep=2pt,outer sep=0pt}}

\begin{document}
\lipsum[1-3]
 \begin{figure}[htb]
  \centering
  \subcaptionbox{}[0.48\linewidth][c]{%
   \begin{tikzpicture}
    \node [mynode,label=above:30] (30) at (0,0) {};
    \node [mynode,below left  = of 30,label=left:2] (2)  {};
    \node [mynode,below right = of 30,label=right:5] (5) {};
    \node [mynode, below = of 30, label=right:3] (3) {};
    \node [mynode,below  = of 3,label=below:1] (1) {};

    \draw (30) -- (2)
          (30) -- (5)
          (30) -- (3)
           (2) -- (1)
           (3) -- (1)
           (5) -- (1);

   \end{tikzpicture}
  }
  \hfill
  \subcaptionbox{}[0.48\linewidth][c]{%
   \begin{tikzpicture}

    \node [mynode,label=above:12] (12) at (0,0) {};
    \node [mynode,below left  = of 12,label=left:4] (4)  {};
    \node [mynode,below right = of 30,label=right:3] (3) {};
    \node [mynode,below left  = of 4,label=left:2] (2)  {};
    \node [below = of 12] (a) {};
    \node[below = of a] (b) {};
    \node[mynode, below of = b, label=right:1] (1) {};

    \draw (12) -- (4)
          (12) -- (3)
           (4) -- (2)
           (2) -- (1)
           (3) -- (1);

   \end{tikzpicture}
  }
  \caption{Some figure}
  \end{figure}
  \begin{figure}\ContinuedFloat
  \subcaptionbox{}[0.48\linewidth][c]{
   \begin{tikzpicture}

    \node [mynode,label=above:10] (10) at (0,0) {};
    \node [mynode,below left  = of 10,label=left:2] (2)  {};
    \node [mynode,below right = of 10,label=right:5] (5) {};
    \node [mynode,below right  = of 2,label=below:1] (1)  {};

    \draw (10) -- (2)
          (10) -- (5)
           (5) -- (1)
           (2) -- (1);
   \end{tikzpicture}
  }
  \hfill
  \subcaptionbox{}[0.48\linewidth][c]{
   \begin{tikzpicture}
    \node [mynode,label=right:16] (16) at (0,0) {};
    \node [mynode, below = of 16, label=right:8] (8) {};
    \node [mynode, below = of 8, label=right:4](4) {};
    \node [mynode, below = of 4, label=right:2] (2){};
    \node [mynode, below = of 2, label=right:1](1){};

    \draw (16) -- (8)
           (8) -- (4)
           (4) -- (2)
           (2) -- (1);
   \end{tikzpicture}
  }
  %\caption{Some figure (cont.)}
  \end{figure}
  \begin{figure}\ContinuedFloat
  \subcaptionbox{}[0.48\linewidth][c]{
   \begin{tikzpicture}
    \node [mynode,label=right:18] (18) at (0,0) {};
    \node [mynode, left = of 18, label=left:12] (12) {};
    \node [mynode, below = of 18, label=right:3](3) {};
    \node [mynode, below = of 12, label=left:2] (2){};

    \draw (18) -- (2)
          (18) -- (3)
          (12) -- (2)
          (12) -- (3);
    \end{tikzpicture}
  }
  \hfill
  \subcaptionbox{}[0.48\linewidth][c]{
   \begin{tikzpicture}

    \node [mynode,label=above:12] (12) at (0,0) {};
    \node [mynode,below left  = of 12,label=left:4] (4)  {};
    \node [below of = 12] (a) {};
    \node [mynode,below right = of 12,label=right:6] (6) {};
    \node [mynode,below = of 4,label=left:2] (2)  {};
    \node [below = of a] (b) {};
    \node [mynode, below = of 6, label=right:3] (3) {};
    \node [mynode, below = of b, label=below:1](1) {};

   \end{tikzpicture}
  }
  %\caption{Some figure (cont.)}
  \end{figure}
  \begin{figure}\ContinuedFloat
  \subcaptionbox{}[0.48\linewidth][c]{
   \begin{tikzpicture}

       \node [mynode,label=above:12] (12) at (0,0) {};
       \node [mynode,below left  = of 12,label=left:4] (4)  {};
       \node [below = of 12] (a) {};
       \node [mynode,below right = of 12,label=right:6] (6) {};
       \node [mynode,below = of 4,label=left:2] (2)  {};
       \node [below = of a] (b) {};
       \node [mynode, below = of 6, label=right:3] (3) {};
       \node [mynode, below = of b, label=below:1](1) {};

      \end{tikzpicture}
  }
  \hfill
  \subcaptionbox{}[0.48\linewidth][c]{
   \begin{tikzpicture}

    \node [mynode,label=above:30] (30) at (0,0) {};
    \node [mynode,below left  = of 30,label=left:6] (6)  {};
    \node [mynode, below = of 30, label=right:10] (10) {};
    \node [mynode,below right = of 30,label=right:15] (15) {};
    \node [mynode,below = of 6,label=left:2] (2)  {};
    \node [mynode, below = of 10, label=right:3] (3) {};
    \node[mynode, below = of 15, label=right:5] (5) {};
    \node[mynode, below = of 3, label=below:1] (1) {};
   \end{tikzpicture}
  }
  \caption{Some figure (cont.)}
 \end{figure}
\lipsum[4-6]
\end{document}

在此处输入图片描述

通过固定的宽度,所有罗马标题数字都可垂直对齐subcaptionbox。请注意,[c选项中的 ]subcaptionboxinner pos默认值(我仍将其添加以供参考)。

答案2

below of=3将得到与 不同的结果below =of 3。您正在混合使用旧语法和positioning库支持的新语法。我建议坚持使用较新的语法,因为这是推荐的。

我试图纠正你的身材,但我不确定它应该是什么样子。

例如,对于最后一张图,使用

  \begin{tikzpicture}

    \node [mynode, label=above:12] (12) at (0,0) {};
    \node [mynode, below left=of 12, label=left:4] (4)  {};
    \node [below=of 12] (a) {};
    \node [mynode, below right=of 12, label=right:6] (6) {};
    \node [mynode, below=of 4, label=left:2] (2)  {};
    \node [below=of a] (b) {};
    \node [mynode, below=of 6, label=right:3] (3) {};
    \node [mynode, below=of b, label=below:1](1) {};

    \draw ;
  \end{tikzpicture}

生产

节点

但我不知道这是否正确。

相关内容