Skip to main content
Extended to real question
Source Link
mrCarnivore
  • 1.6k
  • 3
  • 12

I try to set the color of a cell in a tabularray by a command:

\documentclass{article} \usepackage{xcolor} \usepackage{tabularray} \ExplSyntaxOn \newcommand{\Tcolor}{ green } \ExplSyntaxOff \begin{document} \textcolor{\Tcolor}{abc} \begin{tblr}{ colspec = {l}, cell{1}{1} = {\Tcolor}, } abc \\ \end{tblr} \end{document} 

Somehow the color cell{1}{1} = {\Tcolor}, breaks. Why?

cell{1}{1} = {green}, works...

EDIT: I guess in my attempt to create a MWE I shortened it too much. There is a need for a function instead of a simple color:

\documentclass{article} \usepackage{xcolor} \usepackage{tabularray} \ExplSyntaxOn \newcommand{\Tcolor}[1]{ \int_compare:nNnTF {#1} = {0} { red } { \int_compare:nNnTF {#1} < {30} { orange } { \int_compare:nNnTF {#1} < {40} { green } { blue } } } } \ExplSyntaxOff \begin{document} \textcolor{\Tcolor{32}}{abc} \begin{tblr}{ colspec = {l}, cell{1}{1} = {\Tcolor{32}}, cell{1}{2} = {\Tcolor{48}}, } abc \\ def \\ \end{tblr} \end{document} 

I try to set the color of a cell in a tabularray by a command:

\documentclass{article} \usepackage{xcolor} \usepackage{tabularray} \ExplSyntaxOn \newcommand{\Tcolor}{ green } \ExplSyntaxOff \begin{document} \textcolor{\Tcolor}{abc} \begin{tblr}{ colspec = {l}, cell{1}{1} = {\Tcolor}, } abc \\ \end{tblr} \end{document} 

Somehow the color cell{1}{1} = {\Tcolor}, breaks. Why?

cell{1}{1} = {green}, works...

I try to set the color of a cell in a tabularray by a command:

\documentclass{article} \usepackage{xcolor} \usepackage{tabularray} \ExplSyntaxOn \newcommand{\Tcolor}{ green } \ExplSyntaxOff \begin{document} \textcolor{\Tcolor}{abc} \begin{tblr}{ colspec = {l}, cell{1}{1} = {\Tcolor}, } abc \\ \end{tblr} \end{document} 

Somehow the color cell{1}{1} = {\Tcolor}, breaks. Why?

cell{1}{1} = {green}, works...

EDIT: I guess in my attempt to create a MWE I shortened it too much. There is a need for a function instead of a simple color:

\documentclass{article} \usepackage{xcolor} \usepackage{tabularray} \ExplSyntaxOn \newcommand{\Tcolor}[1]{ \int_compare:nNnTF {#1} = {0} { red } { \int_compare:nNnTF {#1} < {30} { orange } { \int_compare:nNnTF {#1} < {40} { green } { blue } } } } \ExplSyntaxOff \begin{document} \textcolor{\Tcolor{32}}{abc} \begin{tblr}{ colspec = {l}, cell{1}{1} = {\Tcolor{32}}, cell{1}{2} = {\Tcolor{48}}, } abc \\ def \\ \end{tblr} \end{document} 
Made the example shorter
Source Link
mrCarnivore
  • 1.6k
  • 3
  • 12

I try to set the color of a cell in a tabularray by a command:

\documentclass{article} \usepackage{xcolor} \usepackage{tabularray} \ExplSyntaxOn \newcommand{\Tcolor}[1]{ \int_compare:nNnTF {#1} = {0} { red } {   \int_compare:nNnTF {#1} < {30} { orange } { \int_compare:nNnTF {#1} < {40} { green } { blue }  }  }  } \ExplSyntaxOff \begin{document} \textcolor{\Tcolor{32}}{abc} \begin{tblr}{ colspec = {l}, cell{1}{1} = {\Tcolor{32}}, } abc \\ \end{tblr} \end{document} 

Somehow the color cell{1}{1} = {\Tcolor{32}}, breaks. Why?

cell{1}{1} = {green}, works...

I try to set the color of a cell in a tabularray by a command:

\documentclass{article} \usepackage{xcolor} \usepackage{tabularray} \ExplSyntaxOn \newcommand{\Tcolor}[1]{ \int_compare:nNnTF {#1} = {0} { red } {   \int_compare:nNnTF {#1} < {30} { orange } { \int_compare:nNnTF {#1} < {40} { green } { blue }  }  }  } \ExplSyntaxOff \begin{document} \textcolor{\Tcolor{32}}{abc} \begin{tblr}{ colspec = {l}, cell{1}{1} = {\Tcolor{32}}, } abc \\ \end{tblr} \end{document} 

Somehow the color cell{1}{1} = {\Tcolor{32}}, breaks. Why?

I try to set the color of a cell in a tabularray by a command:

\documentclass{article} \usepackage{xcolor} \usepackage{tabularray} \ExplSyntaxOn \newcommand{\Tcolor}{ green } \ExplSyntaxOff \begin{document} \textcolor{\Tcolor}{abc} \begin{tblr}{ colspec = {l}, cell{1}{1} = {\Tcolor}, } abc \\ \end{tblr} \end{document} 

Somehow the color cell{1}{1} = {\Tcolor}, breaks. Why?

cell{1}{1} = {green}, works...

Source Link
mrCarnivore
  • 1.6k
  • 3
  • 12

Why does tabularray not accept colors from commands?

I try to set the color of a cell in a tabularray by a command:

\documentclass{article} \usepackage{xcolor} \usepackage{tabularray} \ExplSyntaxOn \newcommand{\Tcolor}[1]{ \int_compare:nNnTF {#1} = {0} { red } { \int_compare:nNnTF {#1} < {30} { orange } { \int_compare:nNnTF {#1} < {40} { green } { blue } } } } \ExplSyntaxOff \begin{document} \textcolor{\Tcolor{32}}{abc} \begin{tblr}{ colspec = {l}, cell{1}{1} = {\Tcolor{32}}, } abc \\ \end{tblr} \end{document} 

Somehow the color cell{1}{1} = {\Tcolor{32}}, breaks. Why?