强制包含 4 个子图的图形跨越两列

强制包含 4 个子图的图形跨越两列

我试过:

\begin{figure*}
        \centering
        \begin{subfigure}[b]{0.25\textwidth}
                \includegraphics[width=\textwidth]{figures/a}
                \caption{a}
                \label{fig:a}
        \end{subfigure}%

        \begin{subfigure}[b]{0.25\textwidth}
                \includegraphics[width=\textwidth]{figures/b}
                \caption{b}
                \label{fig:b}
        \end{subfigure}

        \begin{subfigure}[b]{0.25\textwidth}
                \includegraphics[width=\textwidth]{figures/c}
                \caption{c}
                \label{fig:c}
        \end{subfigure}
         \begin{subfigure}[b]{0.25\textwidth}
                \includegraphics[width=\textwidth]{figures/d}
                \caption{d}
                \label{fig:d}
        \end{subfigure}
        \caption{Pictures of ABCD}\label{fig:ABCD}
\end{figure*}

但这些数字垂直显示在一列上!我怎样才能让这 4 个数字水平显示在两列上

答案1

子图环境之间的空行会导致图形环境内的换行,因此删除您想要在生成的文档中保留在同一行的那些空行会得到所需的结果:

\begin{figure*}
    \centering
    \begin{subfigure}[b]{0.25\textwidth}
            \includegraphics[width=\textwidth]{figures/a}
            \caption{a}
            \label{fig:a}
    \end{subfigure}
    \begin{subfigure}[b]{0.25\textwidth}
            \includegraphics[width=\textwidth]{figures/b}
            \caption{b}
            \label{fig:b}
    \end{subfigure}

    \begin{subfigure}[b]{0.25\textwidth}
            \includegraphics[width=\textwidth]{figures/c}
            \caption{c}
            \label{fig:c}
    \end{subfigure}
    \begin{subfigure}[b]{0.25\textwidth}
            \includegraphics[width=\textwidth]{figures/d}
            \caption{d}
            \label{fig:d}
    \end{subfigure}
    \caption{Pictures of ABCD}\label{fig:ABCD}
\end{figure*}

附录

如果您想保持源代码的可读性,您也可以“注释掉空白行”——可以这么说:

\begin{figure*}
    \centering
    \begin{subfigure}[b]{0.25\textwidth}
            \includegraphics[width=\textwidth]{figures/a}
            \caption{a}
            \label{fig:a}
    \end{subfigure}
    % this comment avoids break-line...
    \begin{subfigure}[b]{0.25\textwidth}
            \includegraphics[width=\textwidth]{figures/b}
            \caption{b}
            \label{fig:b}
    \end{subfigure}

    \begin{subfigure}[b]{0.25\textwidth}
            \includegraphics[width=\textwidth]{figures/c}
            \caption{c}
            \label{fig:c}
    \end{subfigure}
    % ... this comment too
    \begin{subfigure}[b]{0.25\textwidth}
            \includegraphics[width=\textwidth]{figures/d}
            \caption{d}
            \label{fig:d}
    \end{subfigure}
    \caption{Pictures of ABCD}\label{fig:ABCD}
\end{figure*}

相关内容