2
\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)?

1
  • 1
    You can use \firsthline and \lasthline with tabularray. Commented Jul 29, 2021 at 21:36

4 Answers 4

3

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} 
4
  • Thank you for the answer. Test 2 in tabularray is 0.4pt below baseline and Test 3 0.4pt above baseline. I hope that in a newer version it gets fixed. Commented Jul 30, 2021 at 9:40
  • @polyn Thanks for your reporting. I will look into this problem later. Commented Aug 1, 2021 at 5:24
  • \firsthline and \lasthline were deprecated in favor of baseline=T and baseline=B Commented May 14, 2022 at 11:03
  • 1
    @JayLee Thanks. I have updated the answer accordingly. Commented May 15, 2022 at 1:59
3

May I also suggest trying the NiceTabular environment from the nicematrix package. It lets you specify which line in the table you want to use as baseline.

\documentclass{article} \usepackage{nicematrix} \begin{document} Test 1 \begin{NiceTabular}{c}[baseline=1,hlines,vlines] Test 2 \\ Test 3 \end{NiceTabular} \end{document} 
1
  • It is a good feature. I think tabularray should add it too some day . Commented Jul 30, 2021 at 17:27
1

One option could be to include Test 1 in the table, but without borders around it. You could achieve that using cline :

\documentclass{article} \usepackage{tabularray} \begin{document} \begin{tblr}{Q[c,m]|Q[c,m]|} \cline{2-2} Test 1 & Test 2 \\ \cline{2-2} & Test 3 \\ \cline{2-2} \end{tblr} \end{document} 
2
  • 1
    With tabularray, you can write \cline{2} instead of \cline{2-2}. Commented Jul 29, 2021 at 23:14
  • @Zork thank you for the suggestion. Commented Jul 30, 2021 at 9:45
1

It is not very easy for me to understand this package but you can create every vline and hline yourself with considering the position of the elements of the array. I have thought to this, in function only for your image:

\documentclass{article} \usepackage{tabularray} \begin{document} \begin{tblr}{ hline{1,3} = {2-3}{solid}, hline{2,3} = {2-3}{solid}, vline{2,2} = {1-3}{solid}, vline{3,3} = {1-3}{solid}, vline{2,3} = {2-3}{solid}, } Test 1 & Test 1 \\ & Test 2 \end{tblr} \end{document} 

enter image description here

Addendum: On suggestion of the author of the package @L.J.R. here an improved with the same output (see the comment below):

\documentclass{article} \usepackage{tabularray} \begin{document} \begin{tblr}{ hlines = {2}{solid}, vline{2-3} = {solid}, } Test 1 & Test 1 \\ & Test 2 \end{tblr} \end{document} 

enter image description here

3
  • It is enough with hlines = {2}{solid}, vline{2-3} = {solid}. Commented Jul 29, 2021 at 23:21
  • @Sebastiano thank you for the suggestion. Commented Jul 30, 2021 at 9:44
  • @polyn I'm not expert on this field with this package but I'am very happy to help you. Commented Jul 30, 2021 at 10:19

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.