如何在 latex 中将 4 个独立图形排成一行

如何在 latex 中将 4 个独立图形排成一行

我的代码能够以 2 列格式连续打印 4 个数字。但问题是这些是子图,但我的数字不是子图,它们彼此独立。我尝试删除子浮点数,但它会抛出错误

\begin{figure*}
    \centering
    \setkeys{Gin}{width=.49\linewidth} 
    \begin{minipage}[t]{1\columnwidth}
        \subfloat[AAO]{\label{Fig5:A}\includegraphics{A.png}}\hfill
        \subfloat[BB]{\label{Fig5:B}\includegraphics{B.png}}
        \caption{A and B} \label{Fig5:AB}
    \end{minipage}\hfill % be sure not to leave a blank line
    \begin{minipage}[t]{1\columnwidth}
        \subfloat[C]{\label{Fig6:c}\includegraphics{C.png}}\hfill 
        \subfloat[D]{\label{Fig6:D}\includegraphics{D.png}}
        \caption{C and D} \label{Fig6:CD}
    \end{minipage}
\end{figure*}

答案1

类似下面这样的吗?

在此处输入图片描述

\documentclass[twocolumn, demo]{report} % remove 'demo' option in real document
\usepackage{graphicx}
\begin{document}

\begin{figure*}
\setkeys{Gin}{width=1\linewidth}
\begin{minipage}[t]{0.24\textwidth}
\includegraphics{A}
\caption{A} \label{fig:a}
\end{minipage}\hfill
\begin{minipage}[t]{0.24\textwidth}
\includegraphics{B}
\caption{B} \label{fig:b}
\end{minipage}\hfill
\begin{minipage}[t]{0.24\textwidth}
\includegraphics{C}
\caption{C} \label{fig:c}
\end{minipage}\hfill
\begin{minipage}[t]{0.24\textwidth}
\includegraphics{D}
\caption{D} \label{fig:d}
\end{minipage}
\end{figure*}

\end{document}

答案2

还有一个解决方案,即在表格中排列图形(使用tabularray包),但使用可以在文本中引用图像的标题......

\documentclass[twocolumn, demo]{article} % remove 'demo' option in real document
\usepackage{graphicx}
\usepackage{tabularray}
\UseTblrLibrary{counter,varwidth}   % <===


\begin{document}
    \begin{figure*}
    \setkeys{Gin}{width=\linewidth}
\begin{tblr}{colsep=4pt,
             colspec={@{} *{4}{X[c]}@{}}, 
             measure = vbox}
    \includegraphics{A}
\caption{A} \label{fig:a}
    &
    \includegraphics{B}
\caption{B} \label{fig:b}
    &
    \includegraphics{C}
\caption{C} \label{fig:c}
    &
    \includegraphics{D}
\caption{D} \label{fig:d}
\end{tblr}
    \end{figure*}
\end{document}

答案3

表格中有 4 个数字,分为 4 列:

\documentclass[10pt,a4paper]{article}

\usepackage{graphicx,mwe}

\begin{document}
\setlength\tabcolsep{0pt} % make LaTeX figure out amount of intercol. whitespace
\noindent
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}cccc}  
  \includegraphics[width=.24\textwidth]{example-image-a}
& \includegraphics[width=.24\textwidth]{example-image-b} 
& \includegraphics[width=.24\textwidth]{example-image-c}  
& \includegraphics[width=.24\textwidth]{example-image-a} \\
  Fig. 1 A & Fig. 2 B & Fig. 3 C & Fig. 4 D\\
\end{tabular*}
\end{document}

输出:

在此处输入图片描述

相关内容