子图形的紧密正方形

子图形的紧密正方形

我正在尝试以简单的正方形配置创建一个紧密结合的 4 个子图组。我可以做到这一点,但我想删除空白。

我不确定线宽数字。这是一篇双栏文章,我通过反复试验得出了 0.235。

这是我目前拥有的:

在此处输入图片描述

这是我的代码:

\begin{figure}
 \centering
 \begin{subfigure}[h]{0.235\textwidth}
     \includegraphics[width=\textwidth]{assets/kspace-fac4.jpg}
     \caption{Caption1}
 \end{subfigure}
 \begin{subfigure}[h]{0.235\textwidth}
     \includegraphics[width=\textwidth]{assets/image-fac4.jpg}
     \caption{Caption2}
 \end{subfigure}
 \begin{subfigure}[h]{0.235\textwidth}
     \centering
     \includegraphics[width=\textwidth]{assets/kspace-full.jpg}
     \caption{Caption3}
 \end{subfigure}
 \begin{subfigure}[h]{0.235\textwidth}
     \centering
     \includegraphics[width=\textwidth]{assets/image-full.jpg}
     \caption{Caption4}
     \label{fig:five over x}
 \end{subfigure}
    \caption{Undersampling}
\end{figure}

答案1

在两列文档中使用图像宽度0.35\textwidth,并要求图形位于一列中,而不要求放置在两行中,这会导致图像重叠并不受控制地分成两行。所以我怀疑,你实际上在寻找:

在此处输入图片描述

(红线表示文本边框)

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

\usepackage[demo]{graphicx}     % in real document remove option "demo"
\usepackage{subcaption}

\begin{document}
    \begin{figure*} % figure will span both columns in article
    \setkeys{Gin}{width=\linewidth} % common settings of images widths
\begin{subfigure}{0.235\linewidth}
    \includegraphics{assets/kspace-fac4.jpg}
    \caption{Caption 1}
\end{subfigure}%
    \hfill
\begin{subfigure}{0.235\linewidth}
    \includegraphics{assets/image-fac4.jpg}
    \caption{Caption 2}
\end{subfigure}%
    \hfill
\begin{subfigure}{0.235\linewidth}
    \includegraphics{assets/kspace-full.jpg}
    \caption{Caption 3}
\end{subfigure}
    \hfill
\begin{subfigure}{0.235\linewidth}
    \includegraphics{assets/image-full.jpg}
    \caption{Caption 4}
    \label{fig:five over x}
\end{subfigure}
    \caption{Undersampling}
\end{figure*}
\end{document}

笔记,如果图前有一些文本,图将出现在下一页的顶部!如果您的图像没有获得相同的结果,即周围有更多空白,如上所示,那么您的图像就包含这些空白。要查看这种情况,请\fbox在图像周围添加:

\begin{subfigure}{0.235\linewidth}
    \fbox{\includegraphics{assets/kspace-fac4.jpg}}
    \caption{Caption 1}
\end{subfigure}%

编辑:

如果您希望在一行中放置两张图片,那么您需要在上述文档中做以下更改:

  • 改成\begin{figure*}\begin{figure}[ht]
  • subfigure例如将宽度设置为0.48\columnwidth(或0.48\linewidth
  • 在第二个子图删除\hfill命令之后,插入空白线,并为获得图像行之间更多的垂直距离,\medskip在第三个子图之前插入

这些改变应该产生类似这样的结果:

在此处输入图片描述

相关内容