1

On my new texlive distribution (vanilla texlive 2021 over Ubuntu 20.04), tabularray sometimes doesn't work within gather (from amsmath). For example

\begin{gather*}
 \begin{tblr}{l}
  a \\ b
 \end{tblr}
\end{gather*}

does work, while

\begin{gather*}
 \begin{tblr}{ll}
  a & b
 \end{tblr}
\end{gather*}

does not. An error message is given below

! Undefined control sequence.
! Argument of \__tl_tl_head:w has an extra }.
<inserted text> 
                \par 
l.758     \end{gather*}
Runaway argument?
! Paragraph ended before \__tl_tl_head:w was complete.
<to be read again> 
                   \par 
l.758     \end{gather*}
! Incomplete \ifx; all text was ignored after line 758.
<inserted text> 
                \fi 
l.758     \end{gather*}
etc.

Is it a bug? Does it need to be filed somewhere?

If not, how to correct my code?

2
  • Please see my comment on the answer by @egreg, to the effect that gather isn't the proper environment to use here. Mar 11, 2022 at 17:58
  • @barbara I only put one equation inside to make things more readable.
    – dominique
    Aug 27, 2022 at 14:40

1 Answer 1

2

Add braces.

\documentclass{article}
\usepackage{amsmath,tabularray}

\begin{document}

\begin{gather*}
 \begin{tblr}{l}
  a \\ b
 \end{tblr}
\end{gather*}

\begin{gather*}
 {\begin{tblr}{ll}
  a & b \\
  x+y & u+v
 \end{tblr}}
\end{gather*}

\end{document}

enter image description here

Actually, this should be considered a bug in tabularray, which should have \group_align_safe_begin: and \group_align_safe_end: around its alignments.

Here's the fix, notice that braces are no longer necessary.

\documentclass{article}
\usepackage{amsmath,tabularray}

\ExplSyntaxOn
\cs_set_protected:Npn \__tblr_environ_code:nnnn #1 #2 #3 #4
  {
    \group_align_safe_begin:               % <---- added
    \int_gincr:N \g__tblr_table_count_int
    \tl_set:Nn \l__tblr_env_name_tl {#1}
    \mode_if_math:TF
      { \bool_set_true:N \l__tblr_math_mode_bool }
      { \bool_set_false:N \l__tblr_math_mode_bool }
    \__tblr_builder:nnn {#2} {#3} {#4}
    \group_align_safe_end:                 % <---- added
  }
\ExplSyntaxOff

\begin{document}

\begin{gather*}
 \begin{tblr}{l}
  a \\ b
 \end{tblr}
\end{gather*}

\begin{gather*}
 \begin{tblr}{ll}
  a & b \\
  x+y & u+v
 \end{tblr}
\end{gather*}

\end{document}
4
  • Thanks. I have submitted a bug report and linked your answer on github.com/lvjr/tabularray/issues/211.
    – dominique
    Mar 11, 2022 at 12:52
  • But gather should really be used only on genuinely multi-line material. tblr has the effect of turning its contents into a one-line object. equation* or even \[,,,\] would be more appropriate. Mar 11, 2022 at 17:56
  • @barbarabeeton I guess this was just a simple example.
    – egreg
    Mar 11, 2022 at 18:08
  • Indeed possible, but I've seen so many questions demonstrating that it's not well known, that I have an automatic response. Mar 11, 2022 at 18:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .