加上 varwidth
环境。
\documentclass{article}
\usepackage[a2paper,margin=1in]{geometry}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{graphbox} % thanks to 鱼香肉丝没有鱼先生...
\usepackage{tabularray}
\usepackage{varwidth}
\begin{document}
\begin{tblr}{
colspec={|c|*{4}{Q[c,m,7cm]|}},
rowspec={|*{4}{Q|}},
}
& short text & image without `align=m' & image with `align=m' & long text\\
pure image
& \lipsum[2]
& \begin{varwidth}{7cm}\includegraphics[width=4.8cm]{example-image}\end{varwidth}
& \includegraphics[align=m,width=4.8cm]{example-image}
&\lipsum[1] \\
image with text before
& \lipsum[2]
& {some text before\\ \includegraphics[width=4.8cm]{example-image}}
& {some text before\\ \includegraphics[align=b,width=4.8cm]{example-image}}
& \lipsum[1] \\
image with text after
& \lipsum[2]
& {\begin{varwidth}{7cm}\centering
\includegraphics[width=4.8cm]{example-image}\\ some text after\end{varwidth}}
& {\includegraphics[align=t,width=4.8cm]{example-image}\\ some text after}
& \lipsum[1] \\
\end{tblr}
\end{document}
配合 functional
库,应该可以做到检测 \includegraphics
自动加上 varwidth
环境(留作习题)。
问 在表格中插入【图片】以及【图文混排】如何实现垂直方向的居中对齐?