![如何在插图下方添加单独的标题?](https://linux22.com/image/441802/%E5%A6%82%E4%BD%95%E5%9C%A8%E6%8F%92%E5%9B%BE%E4%B8%8B%E6%96%B9%E6%B7%BB%E5%8A%A0%E5%8D%95%E7%8B%AC%E7%9A%84%E6%A0%87%E9%A2%98%EF%BC%9F.png)
我如何为每幅插图添加单独的标题。左侧插图添加一个标题,右侧插图添加一个标题。两个标题都应位于插图下方。
我所指的插图在下面的代码中给出。
\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}