From tabularray
version 2022A (2022-03-01), \firsthline
and \lasthline
commands are deprecated in favor of baseline=T
and baseline=B
specifications. You can write baseline
option as either an inner specification or an outer specification. And when baseline=T/B
is an outer specification, you can omit the key name and write the value only:
\documentclass{article}
\usepackage{tabularray}
\usepackage{array}
\begin{document}
\section{Tabularray}
Test 1
\begin{tblr}[T]{vlines, colspec={c}}
\hline
Test 2 \\
\hline
Test 3 \\
\hline
\end{tblr}
Test 1
\begin{tblr}[B]{vlines, colspec={c}}
\hline
Test 2 \\
\hline
Test 3 \\
\hline
\end{tblr}
\section{Tabular}
Test 1
\begin{tabular}[t]{|c|}
\firsthline
Test 2 \\
\hline
Test 3 \\
\hline
\end{tabular}
Test 1
\begin{tabular}[b]{|c|}
\hline
Test 2 \\
\hline
Test 3 \\
\lasthline
\end{tabular}
\end{document}
But you can still roll back to version 2021Q with \usepackage{tabularray}[=v2021]
, so that you can use \firsthline
and \lasthline
commands in tblr
environment. The usage is the same as in tabular
environment:
\documentclass{article}
\usepackage{tabularray}[=v2021]
\usepackage{array}
\begin{document}
\section{Tabularray}
Test 1
\begin{tblr}[t]{vlines, colspec={c}}
\firsthline
Test 2 \\
\hline
Test 3 \\
\hline
\end{tblr}
Test 1
\begin{tblr}[b]{vlines, colspec={c}}
\hline
Test 2 \\
\hline
Test 3 \\
\lasthline
\end{tblr}
\section{Tabular}
Test 1
\begin{tabular}[t]{|c|}
\firsthline
Test 2 \\
\hline
Test 3 \\
\hline
\end{tabular}
Test 1
\begin{tabular}[b]{|c|}
\hline
Test 2 \\
\hline
Test 3 \\
\lasthline
\end{tabular}
\end{document}
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}
Best Answer
At
tabularray
in contrary to other tables' packages in each rows regardless if in them are multicolumn cells (written as\SetCell[c=2]{c} ...
) had to be all ampersands as defined in table preamble. In your case, the MWE should be:Edit: For chemical elements (and formulae) is sensible to employ
mhchem
package and write symbol for chlorine\ce{Cl}
or n-clorine$n_{\ce{Cl}}$
.Off-topic: Your table is wider than text area width. So, you may consider the following table preamble:
which gives: