Reputation: 897
I have created a table in Rmarkdown
using the following code:
\begin{tblr}{
row{odd} = {bg=azure8},
row{1} = {bg=azure3, fg=white, font=\sffamily},
}
Number & Model \\
Model 1 & \(BC\_WS = \beta _0 + \beta _1\cdot {M\_WS} + \epsilon\) \\
Model 2 & \(BC\_WS = \beta _0 + f(M\_WS) + \epsilon\) \\
Model 3 & \(BC\_WS = \beta _0 + \beta _1\cdot W\_WS+ \beta _2\cdot W\_Direction+ \beta _3\cdot Temperature + \beta _4\cdot Pressure + \epsilon\) \\
Model 4 & \(BC\_WS = \beta _0 + f(M\_WS)+ f(W\_Direction)+ f(Temperature) + f(Pressure) + \epsilon\) \\
Model 5 & \(BC\_WS =\beta _0 + \beta _1\cdot (M\_WS)+ f(W\_Direction)+ f(Temperature) + f(Pressure) + \epsilon\) \\
Model 6 & \(BC\_WS = \beta _0 + \beta _1\cdot M\_U+ \beta _2\cdot M\_V+ \beta _3\cdot Temperature + \beta _4\cdot Pressure + \epsilon\) \\
Model 7 & \(BC\_WS = \beta _0 + f(M\_U)+ f(M\_V)+ f(Temperature) + f(Pressure) + \epsilon\)
\end{tblr}
and the output looks like this:
How can I customise it so that it results in the following picture? I need to change the colour of rows so that rows and font colour corresponding to model 1, model 3, and model 6 be the same, rows and font colour corresponding to model 2, model 4, and model 7 be the same and
row 5 background colour to be different. There should be aline separting two column and The second column in the first row is centred, so the output is like this:
Upvotes: 3
Views: 5438
Reputation: 38873
Before you use this table, please
note that you shouldn't use math mode for multi-letter words, all the kerning is completely broken...
read http://betterposters.blogspot.com/2012/08/the-data-prison.html and https://texdoc.org/serve/booktabs/0 to get some idea how professional looking tables look like
\documentclass{article}
\usepackage{geometry}
\usepackage{xcolor}
\usepackage{tabularray}
\begin{document}
\begin{tblr}{
colspec={l|[white]l},
cell{1}{2}={halign=c},
rows={bg=lightgray},
row{1}={bg=brown!80,fg=white,font=\bfseries},
row{2}={bg=brown!80!black,fg=white},
row{4}={bg=brown!80!black,fg=white},
row{6}={bg=brown!80!green,fg=white},
row{7}={bg=brown!80!black,fg=white},
}
Number & Model \\
\hline[white,wd=1pt]
Model 1 & \(BC\_WS = \beta _0 + \beta _1\cdot {M\_WS} + \epsilon\) \\
Model 2 & \(BC\_WS = \beta _0 + f(M\_WS) + \epsilon\) \\
Model 3 & \(BC\_WS = \beta _0 + \beta _1\cdot W\_WS+ \beta _2\cdot W\_Direction+ \beta _3\cdot Temperature + \beta _4\cdot Pressure + \epsilon\) \\
Model 4 & \(BC\_WS = \beta _0 + f(M\_WS)+ f(W\_Direction)+ f(Temperature) + f(Pressure) + \epsilon\) \\
Model 5 & \(BC\_WS =\beta _0 + \beta _1\cdot (M\_WS)+ f(W\_Direction)+ f(Temperature) + f(Pressure) + \epsilon\) \\
Model 6 & \(BC\_WS = \beta _0 + \beta _1\cdot M\_U+ \beta _2\cdot M\_V+ \beta _3\cdot Temperature + \beta _4\cdot Pressure + \epsilon\) \\
Model 7 & \(BC\_WS = \beta _0 + f(M\_U)+ f(M\_V)+ f(Temperature) + f(Pressure) + \epsilon\)
\end{tblr}
\end{document}
Upvotes: 3