我想通过重新定义环境tabularray
来使用表格。为此,我需要使用而不是by 。但是,如果我这样做,表格就会像图中一样损坏。这是什么原因造成的,如何解决?lyx
tabular
\tabularnewline
\\
\providecommand{\tabularnewline}{\\}
\documentclass{article}
\usepackage{lmodern}
\usepackage{xcolor}
\usepackage{tabularray}
\providecommand{\tabularnewline}{\\}
\begin{document}
\Large{WRONG}:
\begin{tblr}{|c|c|c|}
\hline
\SetRow{lime!20} Item 1 & Item 2 & Item 3 \tabularnewline
\hline
text & text & text\tabularnewline
\hline
\end{tblr}
\vspace{1cm}
\Large{RIGHT}:
\begin{tblr}{|c|c|c|}
\hline
\SetRow{lime!20} Item 1 & Item 2 & Item 3 \\
\hline
text & text & text\\
\hline
\end{tblr}
\end{document}
答案1
tabularray
必须看到实数,\\
因为它会用实数将数组拆分成行。因此您必须\tabularnewline
先告诉它使用进行扩展[expand=\tabularnewline]
。
\documentclass{article}
\usepackage{lmodern}
\usepackage{xcolor}
\usepackage{tabularray}
\providecommand{\tabularnewline}{\\}
\begin{document}
\Large{RIGHT}:
\begin{tblr}[expand=\tabularnewline]{|c|c|c|}
\hline
\SetRow{lime!20} Item 1 & Item 2 & Item 3 \tabularnewline
\hline
text & text & text\tabularnewline
\hline
\end{tblr}
\end{document}