我如何为每幅插图添加单独的标题。左侧插图添加一个标题,右侧插图添加一个标题。两个标题都应位于插图下方。
我所指的插图在下面的代码中给出。
\begin{figure}[h]
\centering
\caption{Caption}
\usetikzlibrary{arrows.meta,positioning}
\begin{center}
\begin{tikzpicture}[
node distance = 3mm and 20mm,
arr/.style = {draw=blue!70!black, -{Straight Barb[scale=0.8]}, very thick},
N/.style = {font=\small, text width=60mm, align=center, inner sep=2pt},
]
% left image
\node (n1) [N] {Set \mbox{$r_1=0$}\\
Anvend fast vindue $[0,r_2]$};
\draw[thick] (n1.west) -- ++ (0,-24mm)
(n1.east) -- ++ (0,-24mm);
%
\coordinate[below=19mm of n1.west] (aux1);
\path[arr] (n1.east |- aux1) node[right] {$r_2$} --
(aux1) node[left] {$r_2$};
% right image
\node (n2) [N, right=of n1]
{Set \mbox{$r\in[0,r_1-r_2]$}\\
Anvend fast termineringsvindue $[r_1,r_2]$};
\draw[thick] (n2.west) -- ++ (0,-24mm)
(n2.east) -- ++ (0,-24mm);
%
\coordinate[below=19mm of n2.west] (aux2);
\coordinate[above=of aux2] (aux3);
\coordinate[above=of aux3] (aux4);
\path[arr] (n2.east |- aux2) --
(aux2) node[left] {$r_1$};
\path[arr] (n2.east |- aux3) node[right] {$r_2$} -- ++
(-36mm,0) node[left] {$r_1$};
\path[arr] (n2.east |- aux4) -- node[above] {$r_w=r_2-r_1$} ++
(-24mm,0) node[left] {$r_1$};
\end{tikzpicture}
\end{center}
\caption*{(a) ADF test (b) BSADF test}
\label{fig:my_label}
\end{figure}
答案1
一种方法是将图像拆分为两个图像并将每个图像插入到subfloat
环境中:
\documentclass[border=3mm]{article}
\usepackage{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
positioning}
\usepackage{subcaption}
\begin{document}
\begin{figure}[ht]
\tikzset{
node distance = 3mm,
arr/.style = {draw=blue!70!black, -{Straight Barb[scale=0.8]}, very thick},
N/.style = {font=\footnotesize, text width=54mm, align=center, inner sep=2pt},
}
\centering
\subfloat[ADF test]{%
% left image
\begin{tikzpicture}
\node (n1) [N] {Set \mbox{$r_1=0$}\\
Anvend fast vindue $[0,r_2]$};
\draw[thick] (n1.west) -- ++ (0,-24mm)
(n1.east) -- ++ (0,-24mm);
%
\coordinate[below=19mm of n1.west] (aux1);
\path[arr] (n1.east |- aux1) node[right] {$r_2$} --
(aux1) node[left] {$r_2$};
\end{tikzpicture}
}%
\hfill%
\subfloat[BSADF test]{%
% right image
\begin{tikzpicture}
\node (n2) [N] {Set \mbox{$r\in[0,r_1-r_2]$}\\
Anvend fast termineringsvindue $[r_1,r_2]$};
\draw[thick] (n2.west) -- ++ (0,-24mm)
(n2.east) -- ++ (0,-24mm);
%
\coordinate[below=19mm of n2.west] (aux2);
\coordinate[above=of aux2] (aux3);
\coordinate[above=of aux3] (aux4);
\path[arr] (n2.east |- aux2) --
(aux2) node[left] {$r_1$};
\path[arr] (n2.east |- aux3) node[right] {$r_2$} -- ++
(-36mm,0) node[left] {$r_1$};
\path[arr] (n2.east |- aux4) -- node[above] {$r_w=r_2-r_1$} ++
(-24mm,0) node[left] {$r_1$};
\end{tikzpicture}
}
\caption{Caption}
\label{fig:my_label}
\end{figure}
\end{document}
附註: 请求OP:
使用包subfigure
中定义的:subcaption
\documentclass[border=3mm]{article}
\usepackage{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
positioning}
\usepackage{subcaption}
\begin{document}
\begin{figure}[ht]
\tikzset{
node distance = 3mm,
arr/.style = {draw=blue!70!black, -{Straight Barb[scale=0.8]}, very thick},
N/.style = {font=\footnotesize, text width=54mm, align=center, inner sep=2pt},
}
\centering
\caption{Caption}
\label{fig:my_label}
% left image
\begin{subfigure}{0.48\linewidth}
\begin{tikzpicture}
\node (n1) [N] {Set \mbox{$r_1=0$}\\
Anvend fast vindue $[0,r_2]$};
\draw[thick] (n1.west) -- ++ (0,-24mm)
(n1.east) -- ++ (0,-24mm);
%
\coordinate[below=19mm of n1.west] (aux1);
\path[arr] (n1.east |- aux1) node[right] {$r_2$} --
(aux1) node[left] {$r_2$};
\end{tikzpicture}
\caption{ADF test}
\end{subfigure}%
\hfill%
% right image
\begin{subfigure}{0.48\linewidth}
\begin{tikzpicture}
\node (n2) [N] {Set \mbox{$r\in[0,r_1-r_2]$}\\
Anvend fast termineringsvindue $[r_1,r_2]$};
\draw[thick] (n2.west) -- ++ (0,-24mm)
(n2.east) -- ++ (0,-24mm);
%
\coordinate[below=19mm of n2.west] (aux2);
\coordinate[above=of aux2] (aux3);
\coordinate[above=of aux3] (aux4);
\path[arr] (n2.east |- aux2) --
(aux2) node[left] {$r_1$};
\path[arr] (n2.east |- aux3) node[right] {$r_2$} -- ++
(-36mm,0) node[left] {$r_1$};
\path[arr] (n2.east |- aux4) -- node[above] {$r_w=r_2-r_1$} ++
(-24mm,0) node[left] {$r_1$};
\end{tikzpicture}
\caption{BSADF test}
\end{subfigure}
\end{figure}
\end{document}