PdfLaTeX:使用图像自动换行 Table

PdfLaTeX: Auto Wrap in a Table with Images

不好意思又在这里打扰大家了!我正在尝试制作一个table,其中包含多个图像和文本,但是它无法自动换行,并且table变得一团糟......

相关代码为:

\begin{table*}[width=\textwidth,cols=3,pos=h]
    \caption{This is a caption.}
    \begin{tabular*}{\tblwidth}{@{} LLL@{} }
    \toprule
        Iterations & Samples & Comments \
    \midrule
        0    & $\includegraphics[width=.4\textwidth]{000000.png}$ & Training started \
        8    & $\includegraphics[width=.4\textwidth]{000008.png}$ & The text is toooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo long that not all the contents can be shown \
        16   & $\includegraphics[width=.4\textwidth]{000016.png}$ & \
        32   & $\includegraphics[width=.4\textwidth]{000032.png}$ & \
        64   & $\includegraphics[width=.4\textwidth]{000064.png}$ & \
        128  & $\includegraphics[width=.4\textwidth]{000128.png}$ & \
        192  & $\includegraphics[width=.4\textwidth]{000192.png}$ & \
    \bottomrule
    \end{tabular*}
    \label{tab4}
\end{table*}

结果:

顺便说一句,有没有办法让文字和图像(同一行)对齐在同一条中心线上?我尝试使用 \raisebox 但随后来自不同行的图像汇集在一起​​......

您可以使用固定宽度的列,例如m{3cm}tabularx 将自动选择列宽:

\documentclass{article}

\usepackage[export]{adjustbox}
\usepackage{array}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{graphicx}
\def\tabularxcolumn#1{m{#1}}

\begin{document}

\begin{table*}[htbp]
    \caption{This is a caption.}
    \begin{tabularx}{\textwidth}{ @{} l l X @{} }
    \toprule
        Iterations & Samples & Comments \
    \midrule
        0    & $\includegraphics[width=.4\textwidth,valign=M]{example-image-duck}$ & Training started \
        8    & $\includegraphics[width=.4\textwidth,valign=M]{example-image-duck}$ & The text is too oooo oooo ooo ooo oooo oooo oooo oooo oooo oooo oooo oooo oooo ooooo ooo  long that not all the contents can be shown \
        16   & $\includegraphics[width=.4\textwidth,valign=M]{example-image-duck}$ & \
        32   & $\includegraphics[width=.4\textwidth,valign=M]{example-image-duck}$ & \
        64   & $\includegraphics[width=.4\textwidth,valign=M]{example-image-duck}$ & \
        128  & $\includegraphics[width=.4\textwidth,valign=M]{example-image-duck}$ & \
        192  & $\includegraphics[width=.4\textwidth,valign=M]{example-image-duck}$ & \
    \bottomrule
    \end{tabularx}
    \label{tab4}
\end{table*}


\end{document}