I've run into a problem that I can't seem to find a solution. I am using package tabularray
, since I have some long tables. My table has a mix of figures and text, and I would like the left-most column to be aligned in the middle and center. However, I have tried using column{1} = {valign=m}
, cell{2}{1} = {m}
and also \SetRow{m}
, and other options (renewcommand
, using package adjustbox
) to no avail.
Below is a simplified code and the output.
\documentclass{article}
\usepackage{array}
\usepackage{xcolor}
\usepackage{tabularray}
\NewColumnType{M}[1]{>{\centering\arraybackslash}m{#1}}
\usepackage{graphicx}
\begin{document}
\begin{longtblr}[
caption = {My Table},
]{width=\textwidth,
colspec = {| M{0.15\textwidth} | M{0.4\textwidth} | M{0.4\textwidth}|},
rowhead = 1,
row{even} = {gray9},
row{1} = {white},
cell{2}{1} = {m},
% column{1} = {valign=m},
}
\hline
\textbf{Column 1} & \textbf{Column 2} & \textbf{Column 3} \\ \hline
This cell should be centered vertically
& {\includegraphics[width=0.35\textwidth]{example-image} \\ Text that can contain multiple lines but maybe not}
& {\includegraphics[width=0.35\textwidth]{example-image} \\ Text that can contain multiple lines but maybe not} \\ \hline
\end{longtblr}
More text here.
\end{document}
Best Answer
Using
tabularray
package, you should use its syntax, which is quit different form syntax of " classic" table packages. For details see package documentation:If you prefer that text below image is horizontally centered, that use the following
colspec
:For mor vertical padding in rows, you can add to table preamble option
rowsep=<desired amount>
. Default value is2pt
. Similarly you can change column separation bycolsep=<desired amount>
(default is 6pt). For example, considering equal separation between columns and rows gives: