Using tabularray
package, you should use its syntax, which is quit different form syntax of " classic" table packages. For details see package documentation:
\documentclass{article}
\usepackage{array}
\usepackage{xcolor}
\usepackage{tabularray}
\usepackage{graphicx}
\begin{document}
\begin{longtblr}[
caption = {My Table},
label ={tab:l??}]{hlines, vlines,
colspec = {X[0.4,c,m] X[h,j] X[h,j]},
rowhead = 1,
row{even} = {gray9},
row{1} = {font=\bfseries, bg=white},
}
Column 1 & Column 2 & Column 3 \\
This cell should be centered vertically
& \includegraphics[width=\linewidth]{example-image}\par
Text that can contain multiple lines but maybe not
& \includegraphics[width=\linewidth]{example-image}\par
Text that can contain multiple lines but maybe not \\
\end{longtblr}
More text here.
\end{document}
If you prefer that text below image is horizontally centered, that use the following colspec
:
colspec = {X[0.4,c,m] X[h,c]| X[h,c]},
For mor vertical padding in rows, you can add to table preamble option rowsep=<desired amount>
. Default value is 2pt
. Similarly you can change column separation by colsep=<desired amount>
(default is 6pt). For example, considering equal separation between columns and rows gives:
\documentclass{article}
\usepackage{array}
\usepackage{xcolor}
\usepackage{tabularray}
\usepackage{graphicx}
\begin{document}
\begin{longtblr}[
caption = {My Table},
label ={tab:l??}]{hlines, vlines,
colspec = {X[0.4,c,m] X[h,j] X[h,j]},
rowhead = 1,
row{even} = {gray9},
row{1} = {font=\bfseries, bg=white},
%
colsep=4pt, rowsep=4pt, % <-----
}
Column 1 & Column 2 & Column 3 \\
This cell should be centered horizontaly and vertically
& \includegraphics[width=\linewidth]{example-image-duck}\par
Text that can contain multiple lines but maybe not
& \includegraphics[width=\linewidth]{example-image-duck}\par
Text that can contain multiple lines but maybe not \\
\end{longtblr}
More text here.
\end{document}
You need hspan=minimal
option:
\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{tblr}{
colspec={|Q[c,0.1\linewidth]|Q[l,0.4\linewidth]|Q[r,0.45\linewidth]|},
rowspec={|Q[c]|Q[l]|},
hspan=minimal,
}
\SetCell[c=2]{l}{This is a text.This is a text.This is a text.This is a text.This is a text.This is a text.This is a text.This is a text.This is a text.This is a text.This is a text.This is a text.This is a text.} & & DE \\
ABC & ABC & ABC \\
\end{tblr}
\end{document}
Best Answer
You can use your
\nl
command to break multiline cells by usingvarwidth
library oftabularray
package (and you don't need to enclose them with curly braces):