multicols 环境中的 Subfloat

multicols 环境中的 Subfloat

我想将 4 张图片并排放置,并在下方添加一个标题。通常,我会使用以下方法:

\begin{figure}[htb]
\centering
\subfloat{\includegraphics[width=0.25\linewidth]{fig1.pdf}}\hfill
\subfloat{\includegraphics[width=0.25\linewidth]{fig2.pdf}}\hfill
\subfloat{\includegraphics[width=0.25\linewidth]{fig3.pdf}}\hfill
\subfloat{\includegraphics[width=0.25\linewidth]{fig4.pdf}}\hfill
\caption{Single caption underneath all 4 images!}
\label{fig:four-figs}
\end{figure}

但是由于我处于multicols环境中,因此出现以下错误:

包 multicol 警告:在 `multicols' 环境中不允许使用浮点数和边距!。

如何在环境subfloat内实现相同的效果multicols

这是我的 MWE:

\documentclass[a0,portrait]{a0poster}

\usepackage{multicol} 
\columnsep=100pt 
\columnseprule=3pt
\usepackage[svgnames]{xcolor}
\usepackage{palatino} 
\usepackage{graphicx}
\usepackage[font=small,labelfont=bf]{caption} 
\usepackage{amsfonts, amsmath, amsthm, amssymb}
\usepackage{wrapfig}
\usepackage[caption=false]{subfig}
\captionsetup[figure]{labelfont={color=NavyBlue}}

\begin{document}

\begin{multicols}{2} 

\begin{figure}[htb]
\centering
\subfloat{\includegraphics[width=0.25\linewidth]{fig1.pdf}}\hfill
\subfloat{\includegraphics[width=0.25\linewidth]{fig2.pdf}}\hfill
\subfloat{\includegraphics[width=0.25\linewidth]{fig3.pdf}}\hfill
\subfloat{\includegraphics[width=0.25\linewidth]{fig4.pdf}}\hfill
\caption{Single caption underneath all 4 images!}
\label{fig:four-figs}
\end{figure}

\end{multicols}
\end{document}

答案1

无需使用即可获得相同的结果minipage

\documentclass[a0,portrait]{a0poster}

\usepackage{multicol} 
\columnsep=100pt 
\columnseprule=3pt
\usepackage[svgnames]{xcolor}
\usepackage{palatino} 
\usepackage{graphicx}
\usepackage[font=small,labelfont=bf]{caption} 
\usepackage{amsfonts, amsmath, amsthm, amssymb}
\usepackage{wrapfig}
\captionsetup[figure]{labelfont={color=NavyBlue}}

\usepackage{lipsum}

\begin{document}
\begin{multicols}{2} 
\lipsum[1]
\begin{center}
    \includegraphics[width=0.25\linewidth]{fig1.pdf}%
    \includegraphics[width=0.25\linewidth]{fig2.pdf}%
    \includegraphics[width=0.25\linewidth]{fig3.pdf}%
    \includegraphics[width=0.25\linewidth]{fig4.pdf}
\captionof{figure}{Single caption}
\end{center}
\lipsum[2]

\end{multicols}
\end{document}

如果您希望图像之间有空间,则需要减少图像宽度并\hfill在它们之间插入:

\begin{center}
    \includegraphics[width=0.22\linewidth]{fig1.pdf}\hfill
    \includegraphics[width=0.22\linewidth]{fig2.pdf}\hfill
    \includegraphics[width=0.22\linewidth]{fig3.pdf}\hfill
    \includegraphics[width=0.22\linewidth]{fig4.pdf}
\captionof{figure}{Single caption}
\end{center}

答案2

我找到了一个使用包的命令的minipage解决方案。它如下:captionofcaption

\documentclass[a0,portrait]{a0poster}

\usepackage{multicol} 
\columnsep=100pt 
\columnseprule=3pt
\usepackage[svgnames]{xcolor}
\usepackage{palatino} 
\usepackage{graphicx}
\usepackage[font=small,labelfont=bf]{caption} 
\usepackage{amsfonts, amsmath, amsthm, amssymb}
\usepackage{wrapfig}
\captionsetup[figure]{labelfont={color=NavyBlue}}

\begin{document}

\begin{multicols}{2} 

\begin{minipage}{0.25\linewidth}
    \centering
    \includegraphics[width=\linewidth]{fig1.pdf}
\end{minipage}%
\begin{minipage}{0.25\linewidth}
    \centering
    \includegraphics[width=\linewidth]{fig2.pdf}
\end{minipage}%
\begin{minipage}{0.25\linewidth}
    \centering
    \includegraphics[width=\linewidth]{fig3.pdf}
\end{minipage}%
\begin{minipage}{0.25\linewidth}
    \centering
    \includegraphics[width=\linewidth]{fig4.pdf}
\end{minipage}
\captionof{figure}{Single caption}

\end{multicols}
\end{document}

相关内容