Tabularray: align tabular with text

tabularray

\documentclass{article}
\usepackage{tabularray}
\begin{document}
Test 1
\begin{tblr}{hlines, vlines, colspec={c}}
    Test 2 \\
    Test 3 \\
\end{tblr}
\end{document}

enter image description here

How to align Test 1 and Test 2 (same baseline)?

Best Answer

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}

enter image description here


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}