如何重新定位子图中的子标题?

如何重新定位子图中的子标题?

这是我的代码。

\begin{figure}[H]
\centering
\subfloat[$K_4$]
{\begin{tikzpicture}[scale=.65]
\draw[][draw, thick] (0,0) -- (4,0);
\draw[][draw, thick] (0,0) -- (0,4);
\draw[][draw, thick] (4,0) -- (4,4);
\draw[][draw, thick] (0,4) -- (4,4);
\draw[][draw, thick] (0,0) -- (4,4);
\draw[][draw, thick] (0,4)  to[out=50,in=40, distance=6cm] (4,0);


\draw[fill] (0,0) circle [radius=0.1];
\draw[fill] (4,0) circle [radius=0.1];
\draw[fill] (0,4) circle [radius=0.1];
\draw[fill] (4,4) circle [radius=0.1];

\node at (-.3,-.3) {$a$};
\node at (4.3,-.3) {$b$};
\node at (-.3,4.3) {$c$};
\node at (4.3,4.3) {$d$};
\end{tikzpicture}}
\hfill
\subfloat[$K_5$]
{\begin{tikzpicture}[scale=.65]
\draw[][draw, thick] (0,0) -- (4,0);
\draw[][draw, thick] (0,0) -- (0,4);
\draw[][draw, thick] (4,0) -- (4,4);
\draw[][draw, thick] (0,4) -- (4,4);
\draw[][draw, thick] (0,0) -- (4,4);
\draw[][draw, thick] (0,4) -- (4,0);
\draw[][draw, thick] (0,4)  to[out=50,in=40, distance=6cm] (4,0);
\draw[][draw, thick] (0,0)  to[out=140,in=130, distance=6cm] (4,4);

\draw[fill] (0,0) circle [radius=0.1];
\draw[fill] (4,0) circle [radius=0.1];
\draw[fill] (0,4) circle [radius=0.1];
\draw[fill] (4,4) circle [radius=0.1];
\draw[fill] (2,2) circle [radius=0.1];

\node at (-.3,-.3) {$a$};
\node at (4.3,-.3) {$b$};
\node at (-.3,4.3) {$c$};
\node at (4.3,4.3) {$d$};
\node at (2.4,2) {$e$};
\end{tikzpicture}}
\caption{$K_4$ is a planar graph and $K_5$ is a single-crossing graph}
\label{fig:k5k4}
\end{figure}

这就是我得到的。

在此处输入图片描述

有没有办法将子标题放在子图下方。

答案1

此解决方案将额外的空白放在中心 (2,3) 的左侧。我还修剪了多余的空白,原因不明。

\documentclass{article}
\usepackage{subcaption}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}

\begin{figure}[ht]% freinds don't let frineds use [H]
\centering
\subfloat[$K_4$]
{\begin{tikzpicture}[scale=.65]
\draw[][draw, thick] (0,0) -- (4,0);
\draw[][draw, thick] (0,0) -- (0,4);
\draw[][draw, thick] (4,0) -- (4,4);
\draw[][draw, thick] (0,4) -- (4,4);
\draw[][draw, thick] (0,0) -- (4,4);
\begin{scope}
  \clip (0,0) rectangle (6,6);
  \draw[][draw, thick] (0,4)  to[out=50,in=40, distance=6cm] (4,0);
\end{scope}


\draw[fill] (0,0) circle [radius=0.1];
\draw[fill] (4,0) circle [radius=0.1];
\draw[fill] (0,4) circle [radius=0.1];
\draw[fill] (4,4) circle [radius=0.1];

\node at (-.3,-.3) {$a$};
\node at (4.3,-.3) {$b$};
\node at (-.3,4.3) {$c$};
\node at (4.3,4.3) {$d$};

\path ($(current bounding box.east)!2!(2,3)$);% cnter square in image
\draw[red] (current bounding box.south west) rectangle (current bounding box.north east);% show bounding box
\end{tikzpicture}}%
\hfill
\subfloat[$K_5$]
{\begin{tikzpicture}[scale=.65]
\draw[][draw, thick] (0,0) -- (4,0);
\draw[][draw, thick] (0,0) -- (0,4);
\draw[][draw, thick] (4,0) -- (4,4);
\draw[][draw, thick] (0,4) -- (4,4);
\draw[][draw, thick] (0,0) -- (4,4);
\draw[][draw, thick] (0,4) -- (4,0);
\begin{scope}
  \clip (-2,0) rectangle (6,6);
  \draw[][draw, thick] (0,4)  to[out=50,in=40, distance=6cm] (4,0);
  \draw[][draw, thick] (0,0)  to[out=140,in=130, distance=6cm] (4,4);
\end{scope}

\draw[fill] (0,0) circle [radius=0.1];
\draw[fill] (4,0) circle [radius=0.1];
\draw[fill] (0,4) circle [radius=0.1];
\draw[fill] (4,4) circle [radius=0.1];
\draw[fill] (2,2) circle [radius=0.1];

\node at (-.3,-.3) {$a$};
\node at (4.3,-.3) {$b$};
\node at (-.3,4.3) {$c$};
\node at (4.3,4.3) {$d$};
\node at (2.4,2) {$e$};
\draw[red] (current bounding box.south west) rectangle (current bounding box.north east);% show bounding box
\end{tikzpicture}}
\caption{$K_4$ is a planar graph and $K_5$ is a single-crossing graph}
\label{fig:k5k4}
\end{figure}

\end{document}

此版本使用更少的空间,但您必须小心不要重叠图像。

\documentclass{article}
\usepackage{subcaption}
\usepackage{tikz}

\begin{document}

\begin{figure}[ht]% freinds don't let frineds use [H]
\centering
\subfloat[$K_4$]
{\begin{tikzpicture}[scale=.65]
\draw[][draw, thick] (0,0) -- (4,0);
\draw[][draw, thick] (0,0) -- (0,4);
\draw[][draw, thick] (4,0) -- (4,4);
\draw[][draw, thick] (0,4) -- (4,4);
\draw[][draw, thick] (0,0) -- (4,4);
\begin{pgfinterruptboundingbox}
  \draw[][draw, thick] (0,4)  to[out=50,in=40, distance=6cm] (4,0);
\end{pgfinterruptboundingbox}

\draw[fill] (0,0) circle [radius=0.1];
\draw[fill] (4,0) circle [radius=0.1];
\draw[fill] (0,4) circle [radius=0.1];
\draw[fill] (4,4) circle [radius=0.1];

\node at (-.3,-.3) {$a$};
\node at (4.3,-.3) {$b$};
\node at (-.3,4.3) {$c$};
\node at (4.3,4.3) {$d$};

\draw[red] (current bounding box.south west) rectangle (current bounding box.north east);% show bounding box
\end{tikzpicture}}%
\hfill
\subfloat[$K_5$]
{\begin{tikzpicture}[scale=.65]
\draw[][draw, thick] (0,0) -- (4,0);
\draw[][draw, thick] (0,0) -- (0,4);
\draw[][draw, thick] (4,0) -- (4,4);
\draw[][draw, thick] (0,4) -- (4,4);
\draw[][draw, thick] (0,0) -- (4,4);
\draw[][draw, thick] (0,4) -- (4,0);
\begin{pgfinterruptboundingbox}
  \draw[][draw, thick] (0,4)  to[out=50,in=40, distance=6cm] (4,0);
  \draw[][draw, thick] (0,0)  to[out=140,in=130, distance=6cm] (4,4);
\end{pgfinterruptboundingbox}

\draw[fill] (0,0) circle [radius=0.1];
\draw[fill] (4,0) circle [radius=0.1];
\draw[fill] (0,4) circle [radius=0.1];
\draw[fill] (4,4) circle [radius=0.1];
\draw[fill] (2,2) circle [radius=0.1];

\node at (-.3,-.3) {$a$};
\node at (4.3,-.3) {$b$};
\node at (-.3,4.3) {$c$};
\node at (4.3,4.3) {$d$};
\node at (2.4,2) {$e$};
\draw[red] (current bounding box.south west) rectangle (current bounding box.north east);% show bounding box
\end{tikzpicture}}
\caption{$K_4$ is a planar graph and $K_5$ is a single-crossing graph}
\label{fig:k5k4}
\end{figure}

\end{document}

答案2

作为对 @John Kormylo 的精彩回答 (+1) 的补充。应谨慎使用:定位子浮动时仅考虑正方形,因此可能会发生其中的图像重叠的情况。此外,图像可以与图像上方的文本重叠。

\vspace*{<v distance>}可以通过在\begin{figure}和之后插入来防止这种情况\hspace{<h distance}。两个距离的大小可以通过以下方式确定反复试验方法:

\documentclass{article}
\usepackage{subcaption}
\usepackage{tikz}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{lipsum}

\begin{document}
\lipsum[11]
    \begin{figure}[ht]
    \vspace*{12mm}  % <-------
\subfloat[$K_4$]
{%
    \begin{tikzpicture}[scale=0.8]
\draw[thick] (0,0) rectangle (4,4);
\draw[thick,fill] (0,0) node[below  left] {$a$} circle [radius=0.1] -- 
                  (4,4) node[above right] {$d$} circle [radius=0.1]
                  (0,4) node[above  left] {$c$} circle [radius=0.1]    
                  (4,0) node[below right] {$b$} circle [radius=0.1];
\begin{pgfinterruptboundingbox}
  \draw[thick] (0,4)  to[out=50,in=40, distance=6cm] (4,0);
\end{pgfinterruptboundingbox}
%
\draw[red] (current bounding box.south west)
                rectangle (current bounding box.north east);% show bounding box
\end{tikzpicture}
}%
\hspace{22mm}   % <-------
\subfloat[$K_5$]
{
    \begin{tikzpicture}[scale=0.8]
\draw[thick] (0,0) rectangle (4,4);
\draw[thick,fill] (0,0) node[below  left] {$a$} circle [radius=0.1] --
                  (4,4) node[above right] {$d$} circle [radius=0.1]
                  (0,4) node[above  left] {$c$} circle [radius=0.1] --
                  (4,0) node[below right] {$b$} circle [radius=0.1];
\node[right] at (2,2) {$e$};
\begin{pgfinterruptboundingbox}
  \draw[thick] (0,4)  to[out=50,in=40,   distance=6cm] (4,0);
  \draw[thick] (0,0)  to[out=140,in=130, distance=6cm] (4,4);
\end{pgfinterruptboundingbox}
%
\draw[red] (current bounding box.south west) 
                rectangle (current bounding box.north east);% show bounding box
\end{tikzpicture}
}
    \caption{$K_4$ is a planar graph and $K_5$ is a single-crossing graph}
    \label{fig:k5k4}
    \end{figure}
\end{document}

如您所见,您的 MWE 已被部分重写,变得更加紧凑和简短。

在此处输入图片描述

(红线表示页面布局)

相关内容