add tag
Laurenso
I have longtable
```
\documentclass[12pt]{article}
\usepackage{tabularray}
\UseTblrLibrary{diagbox}
\UseTblrLibrary{varwidth}
\UseTblrLibrary{booktabs}
\UseTblrLibrary{counter}
\usepackage{enumitem}
\usepackage{ninecolors}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{siunitx}
\sisetup{output-decimal-marker={,}}
\UseTblrLibrary{siunitx} 
\usepackage[paperwidth=19cm, paperheight=26.5cm, left=1.7cm,right=1.7cm,top=1.8cm,bottom=1.7cm]{geometry}
\DefTblrTemplate{contfoot-text}{normal}{Continued on next page}
\SetTblrTemplate{contfoot-text}{normal}
\DefTblrTemplate{conthead-text}{normal}{(Continued)}
\SetTblrTemplate{conthead-text}{normal}
\SetTblrTemplate{conthead-text}{normal}
\newcounter{mycnta}
\newcommand{\mycnta}{\stepcounter{mycnta}\arabic{mycnta}}
\begin{document}
	\begin{longtblr}[
		caption={Some text}]{
			colspec = {Q[c,gray9]X[l]Q[c]},
			vlines,
			hlines,
row{1}={yellow9,font=\bfseries},
cell{2,7,11}{2-3} ={teal9},
%cell{7}{2-3} ={teal9},
%cell{11}{2-3} ={teal9},
hline{1,2,Y,Z} = {solid},
cell{1}{2-3}={halign=c},
column{1}={font=\bfseries},
cell{2-Z}{1}={cmd={\mycnta}},}
Problem & Content & Point \\
\SetCell[r=5]{m}	& Solve the equation $ x^2 - 5x + 6 = 0 $ &  \num{1.00}   \\
		& $ \Delta =(-5)^2 - 4 \cdot 1 \cdot 6 = 1$, & \num{0.25} \\
		& $ x = \dfrac{-(-5) -1}{2} = 2$. & \num{0.25} \\
		& $ x = \dfrac{-(-5)  + 1}{2} = 3$ & \num{0.25} \\
		& The given equation has two solutions $x=2$ and $x = 3$. & \num{0.25} \\
		\SetCell[r=4]{m}	& Find the derivaty of the function $ y = \dfrac{2x+1}{x-2} $ &  \num{0.75}  \\
		& $ y' = \dfrac{(2x+1)'(x-2)-(2x+1)(x-2)'}{(x-2)^2}$. & \num{0.25} \\
		& $ y'=\dfrac{2(x-2) -(2x+1)}{(x-2)^2}$. & \num{0.25} \\
		& $y'=-\dfrac{5}{(x-2)^2}$. & \num{0,25} \\
		\SetCell[r=3]{m}	& Is this $ x^2 + 3x +4 >0$ true or fail? why?  &  \num{0.75}  \\
		&  $ x^2 + 3x +4 >0$ true. & \num{0.25} \\
		& $ x^2 + 3x +4 $ have $ \Delta = -7<0 $ and coefficient of  $ x^2 $ is $ 1 >0$. & \num{0.50}
		\\
		\SetCell[r=5]{m}	& Solve the equation $ x^2 - 5x + 6 = 0 $ &  \num{1.00}   \\
		& $ \Delta =(-5)^2 - 4 \cdot 1 \cdot 6 = 1$, & \num{0.25} \\
		& $ x = \dfrac{-(-5) -1}{2} = 2$. & \num{0.25} \\
		& $ x = \dfrac{-(-5)  + 1}{2} = 3$ & \num{0.25} \\
		& The given equation has two solutions $x=2$ and $x = 3$. & \num{0.25} \\
		\SetCell[r=4]{m}	& Find the derivaty of the function $ y = \dfrac{2x+1}{x-2} $ &  \num{0.75}  \\
		& $ y' = \dfrac{(2x+1)'(x-2)-(2x+1)(x-2)'}{(x-2)^2}$. & \num{0.25} \\
		& $ y'=\dfrac{2(x-2) -(2x+1)}{(x-2)^2}$. & \num{0.25} \\
		& $y'=-\dfrac{5}{(x-2)^2}$. & \num{0,25} \\
		\SetCell[r=3]{m}	& Is this $ x^2 + 3x +4 >0$ true or fail? why?  &  \num{0.75}  \\
		&  $ x^2 + 3x +4 >0$ true. & \num{0.25} \\
		& $ x^2 + 3x +4 $ have $ \Delta = -7<0 $ and coefficient of  $ x^2 $ is $ 1 >0$. & \num{0.50}
		\\
		\SetCell[r=5]{m}	& Solve the equation $ x^2 - 5x + 6 = 0 $ &  \num{1.00}   \\
		& $ \Delta =(-5)^2 - 4 \cdot 1 \cdot 6 = 1$, & \num{0.25} \\
		& $ x = \dfrac{-(-5) -1}{2} = 2$. & \num{0.25} \\
		& $ x = \dfrac{-(-5)  + 1}{2} = 3$ & \num{0.25} \\
		& The given equation has two solutions $x=2$ and $x = 3$. & \num{0.25} \\
		\SetCell[r=4]{m}	& Find the derivaty of the function $ y = \dfrac{2x+1}{x-2} $ &  \num{0.75}  \\
		& $ y' = \dfrac{(2x+1)'(x-2)-(2x+1)(x-2)'}{(x-2)^2}$. & \num{0.25} \\
		& $ y'=\dfrac{2(x-2) -(2x+1)}{(x-2)^2}$. & \num{0.25} \\
		& $y'=-\dfrac{5}{(x-2)^2}$. & \num{0,25} \\
		\SetCell[r=3]{m}	& Is this $ x^2 + 3x +4 >0$ true or fail? why?  &  \num{0.75}  \\
		&  $ x^2 + 3x +4 >0$ true. & \num{0.25} \\
		& $ x^2 + 3x +4 $ have $ \Delta = -7<0 $ and coefficient of  $ x^2 $ is $ 1 >0$. & \num{0.50}
	\end{longtblr} 
\end{document}
```
![image.png](/image?hash=44c1a8250156a069facf5858e3e2abd9f635a981ff72ee62cf458d09153e192d)


![image.png](/image?hash=f4566b0a5cd21c0be552bbd9b640a19dba59ce639b5714eb98cb0bdbbc05221a)

I used `cell{2,7,11}{2-3} ={teal9},` to color this lines. How can I color the first rows of each Problem automatically?
Top Answer
samcarter
Here a semi-automatic approach: instead of the `\SetCell[r=...]{m}` instruction, you could create a custom command with a mandatory argument x which 

- merges the x cells
- changes the colour of this row
- changes the colour of this cell back to gray
- increases the problem counter and inserts the number

```
\documentclass[12pt]{article}
\usepackage{tabularray}
\UseTblrLibrary{diagbox}
\UseTblrLibrary{varwidth}
\UseTblrLibrary{booktabs}
\UseTblrLibrary{counter}
\usepackage{enumitem}
\usepackage{ninecolors}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{siunitx}
\sisetup{output-decimal-marker={,}}
\UseTblrLibrary{siunitx} 
\usepackage[paperwidth=19cm, paperheight=26.5cm, left=1.7cm,right=1.7cm,top=1.8cm,bottom=1.7cm]{geometry}
\DefTblrTemplate{contfoot-text}{normal}{Continued on next page}
\SetTblrTemplate{contfoot-text}{normal}
\DefTblrTemplate{conthead-text}{normal}{(Continued)}
\SetTblrTemplate{conthead-text}{normal}
\SetTblrTemplate{conthead-text}{normal}
\newcounter{mycnta}
\newcommand{\mycnta}{\stepcounter{mycnta}\arabic{mycnta}}


\newcommand{\startproblem}[1]{
  \SetCell[r=#1]{m}\SetRow{bg=teal9}\SetCell{bg=gray9}\mycnta
}

\begin{document}
	\begin{longtblr}[
    expand=\startproblem,
		caption={Some text}]{
			colspec = {Q[c]X[l]Q[c]},
			vlines,
			hlines,
      row{1}={yellow9,font=\bfseries},
      cell{1}{2-3}={halign=c},
      column{1}={font=\bfseries},
}
Problem & Content & Point \\
\startproblem{5}	& Solve the equation $ x^2 - 5x + 6 = 0 $ &  \num{1.00}   \\
		& $ \Delta =(-5)^2 - 4 \cdot 1 \cdot 6 = 1$, & \num{0.25} \\
		& $ x = \dfrac{-(-5) -1}{2} = 2$. & \num{0.25} \\
		& $ x = \dfrac{-(-5)  + 1}{2} = 3$ & \num{0.25} \\
		& The given equation has two solutions $x=2$ and $x = 3$. & \num{0.25} \\
		\startproblem{4}	& Find the derivaty of the function $ y = \dfrac{2x+1}{x-2} $ &  \num{0.75}  \\
		& $ y' = \dfrac{(2x+1)'(x-2)-(2x+1)(x-2)'}{(x-2)^2}$. & \num{0.25} \\
		& $ y'=\dfrac{2(x-2) -(2x+1)}{(x-2)^2}$. & \num{0.25} \\
		& $y'=-\dfrac{5}{(x-2)^2}$. & \num{0,25} \\
		\startproblem{3}	& Is this $ x^2 + 3x +4 >0$ true or fail? why?  &  \num{0.75}  \\
		&  $ x^2 + 3x +4 >0$ true. & \num{0.25} \\
		& $ x^2 + 3x +4 $ have $ \Delta = -7<0 $ and coefficient of  $ x^2 $ is $ 1 >0$. & \num{0.50}
		\\
		\startproblem{5}	& Solve the equation $ x^2 - 5x + 6 = 0 $ &  \num{1.00}   \\
		& $ \Delta =(-5)^2 - 4 \cdot 1 \cdot 6 = 1$, & \num{0.25} \\
		& $ x = \dfrac{-(-5) -1}{2} = 2$. & \num{0.25} \\
		& $ x = \dfrac{-(-5)  + 1}{2} = 3$ & \num{0.25} \\
		& The given equation has two solutions $x=2$ and $x = 3$. & \num{0.25} \\
		\startproblem{4}	& Find the derivaty of the function $ y = \dfrac{2x+1}{x-2} $ &  \num{0.75}  \\
		& $ y' = \dfrac{(2x+1)'(x-2)-(2x+1)(x-2)'}{(x-2)^2}$. & \num{0.25} \\
		& $ y'=\dfrac{2(x-2) -(2x+1)}{(x-2)^2}$. & \num{0.25} \\
		& $y'=-\dfrac{5}{(x-2)^2}$. & \num{0,25} \\
		\startproblem{3}	& Is this $ x^2 + 3x +4 >0$ true or fail? why?  &  \num{0.75}  \\
		&  $ x^2 + 3x +4 >0$ true. & \num{0.25} \\
		& $ x^2 + 3x +4 $ have $ \Delta = -7<0 $ and coefficient of  $ x^2 $ is $ 1 >0$. & \num{0.50}
		\\
		\startproblem{5}	& Solve the equation $ x^2 - 5x + 6 = 0 $ &  \num{1.00}   \\
		& $ \Delta =(-5)^2 - 4 \cdot 1 \cdot 6 = 1$, & \num{0.25} \\
		& $ x = \dfrac{-(-5) -1}{2} = 2$. & \num{0.25} \\
		& $ x = \dfrac{-(-5)  + 1}{2} = 3$ & \num{0.25} \\
		& The given equation has two solutions $x=2$ and $x = 3$. & \num{0.25} \\
		\startproblem{4}	& Find the derivaty of the function $ y = \dfrac{2x+1}{x-2} $ &  \num{0.75}  \\
		& $ y' = \dfrac{(2x+1)'(x-2)-(2x+1)(x-2)'}{(x-2)^2}$. & \num{0.25} \\
		& $ y'=\dfrac{2(x-2) -(2x+1)}{(x-2)^2}$. & \num{0.25} \\
		& $y'=-\dfrac{5}{(x-2)^2}$. & \num{0,25} \\
		\startproblem{3}	& Is this $ x^2 + 3x +4 >0$ true or fail? why?  &  \num{0.75}  \\
		&  $ x^2 + 3x +4 >0$ true. & \num{0.25} \\
		& $ x^2 + 3x +4 $ have $ \Delta = -7<0 $ and coefficient of  $ x^2 $ is $ 1 >0$. & \num{0.50}
	\end{longtblr} 
\end{document}
```
![document.png](/image?hash=7092896884f5607e966cda52eb056c3d96beea2f6b5871ba32b434ef1ef02266)

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.