1
\documentclass[preview,varwidth]{standalone}
\usepackage{graphicx}

\begin{document}
\begin{figure}
    \centering
    \setlength{\tabcolsep}{0.3mm}
    \begin{tabular}[0mm]{cccc}
    \includegraphics[width=2cm]{example-image-a} &
    \includegraphics[width=2cm]{example-image-b} &
    \includegraphics[width=2cm]{example-image-c} &
    \includegraphics[width=2cm]{example-image-c} \\
    A text & A long B text & C text & D text
    \end{tabular}
\end{figure}
\end{document}

It produces:

result

Note "A long B text" streches the table, and ruin the first row.

I would like the column width to be "floating", i.e.

  • for first row: the four figures stay closely, like image "C" to image "C";
  • for second row: "A long B text" has flexiable larger width than other columns, and at the same time align with first row.

How can I do this?

2
  • 1
    Why not work with \begin{tabular}{p{...cm}p{...cm}p{...cm}p{...cm}} for row 1 and using @{\extracolsep{\fill}} for row 2?
    – aerioeus
    Apr 16, 2018 at 23:15
  • @aerioeus I have tried I may not get the idea... Could you please hint more on that?
    – WDC
    Apr 17, 2018 at 11:32

1 Answer 1

2

I think setting a box with 0 width for the long description is enough.

\documentclass[preview,varwidth]{standalone}
\usepackage{graphicx}

\begin{document}
\begin{figure}
    \centering
    \setlength{\tabcolsep}{0.3mm}
    \begin{tabular}[0mm]{cccc}
    \includegraphics[width=2cm]{example-image-a} &
    \includegraphics[width=2cm]{example-image-b} &
    \includegraphics[width=2cm]{example-image-c} &
    \includegraphics[width=2cm]{example-image-c} \\
    A text & \makebox[0pt]{A long B text} & C text & D text
    \end{tabular}
\end{figure}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .