对齐子图和子标题

对齐子图和子标题

我使用“表格”选项来显示子图和子标题。以下是我的代码。

    \begin{figure}[!t]
\centering
\begin{tabular}{@{}c@{}}
    \includegraphics[width=4.3cm, height=4.3cm]{NITRA_pep_inp} \\[\abovecaptionskip]
    \small (a) Input peppers image
    \label{cari1}
\end{tabular}
\begin{tabular}{@{}c@{}}
    \includegraphics[width=4.3cm, height=4.3cm]{NITRA_pep_out_20} \\[\abovecaptionskip]
    \small (b) Reconstructed Peppers Image \\
    \small M=20, PSNR = 30.9370 dB \\
    \label{caro1}
\end{tabular}
\vskip\baselineskip
\begin{tabular}{@{}c@{}}
    \includegraphics[width=4.3cm, height=4.3cm]{NITRA_pep_inp} \\[\abovecaptionskip]
    \small (a) Input frame (eg) (Akiyo series)
    \label{aki1}
\end{tabular}
\begin{tabular}{@{}c@{}}
    \includegraphics[width=4.3cm, height=4.3cm]{NITRA_pep_out_20} \\[\abovecaptionskip]
    \small (b) Reconstructed frame (eg) (Akiyo series) \\
    \small M = 20, PSNR = 34.7404 dB
    \label{akio2}
\end{tabular}
\caption{Reconstructed images and video frames using NITRA with number of measurements and their corresponding PSNR in dB}
\label{NITRAres1}
    \end{figure}

我得到的结果图像如下: 最终图片

我应该如何更改代码以使子图和子标题正确对齐?'Subfigure' 和 'subcaption' 对我来说效果不佳,这就是我选择 'tabular' 的原因。

答案1

用 替换这四个\begin{tabular}{@{}c@{}}指令\begin{tabular}[t]{@{}c@{}}将解决直接(垂直)对齐问题。但是,环境\label中的四个指令tabular将继续不起作用,因为它们与通过 等机制递增的任何计数器无关\refstepcounter

因此,我建议您 (a) 加载subcaption包(顺便说一下,它适用于大多数文档类),(b) 用tabular环境替换subfigure环境,以及 (c)\caption在每个环境中使用指令subfigure。这样,子图也可以单独交叉引用。

\documentclass[demo]{article} % remove 'demo' option in real document
\usepackage{graphicx,subcaption}
\begin{document}
\begin{figure}[!t]
\centering
\begin{subfigure}[t]{4.5cm}
\includegraphics[width=\linewidth, height=\linewidth]{NITRA_pep_inp} 
\caption{Input peppers image}
\label{cari1}
\end{subfigure}
\qquad % some horizontal space
\begin{subfigure}[t]{4.5cm}
\includegraphics[width=\linewidth, height=\linewidth]{NITRA_pep_out_20}
\caption{Reconstructed Peppers Image, M=20, PSNR = 30.9370 dB} 
\label{caro1}
\end{subfigure}

\vspace{\baselineskip}

\begin{subfigure}[t]{4.5cm}
\includegraphics[width=\linewidth, height=\linewidth]{NITRA_pep_inp}
\caption{Input frame (Akiyo series)}
\label{aki1}
\end{subfigure} 
\qquad % some horizontal space
\begin{subfigure}[t]{4.5cm}
\includegraphics[width=\linewidth, height=\linewidth]{NITRA_pep_out_20}
\caption{Reconstructed frame (Akiyo series), M = 20, PSNR = 34.7404 dB} 
\label{akio2}
\end{subfigure}

% caption for overall figure env.:
\caption{Reconstructed images and video frames using NITRA with 
number of measurements and their corresponding PSNR in dB}
\label{NITRAres1} 
\end{figure}

A cross-reference to figure \ref{akio2}.
\end{document}

相关内容