3

When using multiline cells with tabularray like in the example below, I have the problem that my editor (emacs) recognizes the \\ that indicate a newline in a cell as the end of a row and thus messes up aligning the table in the editor. So is there a way to use another command instead of \\ for the multiline cells or map it to another macro. I tried \newcommand{\nl}{\\}, but this doesn' work (it stretches the table to the right).

\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{tblr}{colspec={clr},hlines}
    one & {left\\leftttt} & three          \\
    one & two             & {right\\rightttt} \\
\end{tblr}
\end{document}

(Example from here).

Julia
  • 1,648
  • See https://tex.stackexchange.com/a/630796/250119 for a working hack for that. (also maybe ask L.J.R to implement it "officially" as a feature (possibly with a warning), it's not like tabularnewline has another usage anyway) – user202729 Jun 22 '22 at 12:14
  • You could use \cr whithin tables – alvaro martinez Jun 23 '22 at 15:16

1 Answers1

5

You can use your \nl command to break multiline cells by using varwidth library of tabularray package (and you don't need to enclose them with curly braces):

\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{varwidth}
\SetTblrInner[tblr]{measure=vbox}
\newcommand{\nl}{\\}
\begin{document}

\begin{tblr}{colspec={clr},hlines} one & left\nl leftttt & three \ center\nl centerrrr & two & right\nl rightttt \ \end{tblr}

\bigskip

\begin{tblr}{colspec={clr},hlines} one & {left\leftttt} & three \ {center\centerrrr} & two & {right\rightttt} \ \end{tblr}

\end{document}

enter image description here

L.J.R.
  • 10,932