自動將影像陣列置於表格儲存格內的中心

自動將影像陣列置於表格儲存格內的中心

我有這樣的表:

\begin{tabular}{p{0.5\textwidth}|p{0.5\textwidth}}
caption1 & caption2 \\
\includegraphics[params]{path11} \includegraphics[params]{path12} ... \includegraphics[params]{path1N} & \includegraphics[params]{path21} \includegraphics[params]{path22} ... \includegraphics[params]{path2N} \\ 
\end{tabular}

我希望圖像像數組一樣,但它們應該考慮列寬,並在沒有空間時自動創建新的圖像行。所有影像應均勻放置並留有邊距,以免相互接觸。

答案1

您需要將圖像放入\multicolumn{2}{c}{...}巨集中,然後可以\hfill在它們之間添加以在它們之間獲得一些邊距。您需要將長度設定得足夠小paramswidth=<some length>

這是一個包含三個圖像的範例:

\documentclass{article}
\usepackage{graphicx}
\begin{document}

\begin{tabular}{p{0.49\textwidth}|p{0.49\textwidth}}
    caption1 & caption2 \\
    \multicolumn{2}{c}{%
    \includegraphics[width=.3\textwidth]{example-image-a} \hfill
    \includegraphics[width=.3\textwidth]{example-image-b} \hfill
    \includegraphics[width=.3\textwidth]{example-image-c}
    }
\end{tabular}

\end{document}

如果您需要垂直對齊影像,請參閱如何製作一個圖像居中的表格?或者如何將表格中的圖片左上角對齊?

相關內容