Search code examples
latexr-markdowntablerowtablecolumn

customizing latex table color and adding footnote


Given the following code, I would like to remove the colours and add a third column including *, **, *** to show the grouping of, for example, 2,4 and 7 and... and then in the footnote what each start group mean.

\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 &  \(\text{BC\_WS} = \beta _0 + \beta _1\cdot {\text{M\_WS}} + \epsilon\) \\
Model 2 &  \(\text{BC\_WS} = \beta _0 + f(\text{M\_WS}) + \epsilon\) \\
Model 3 &  \(\text{BC\_WS} = \beta _0 + \beta _1\cdot W\_WS+ \beta _2\cdot \text{\text{W\_Direction}}+  \beta _3\cdot \text{Temperature} + \beta _4\cdot \text{Pressure}  + \epsilon\) \\
Model 4 &  \(\text{BC\_WS} = \beta _0 + f(\text{M\_WS})+  f(\text{W\_Direction})+ f(\text{Temperature}) + f(\text{Pressure})  + \epsilon\) \\
Model 5 &  \(\text{BC\_WS} =\beta _0 + \beta _1\cdot (\text{M\_WS})+  f(\text{W\_Direction})+ f(\text{Temperature}) + f(\text{Pressure})  + \epsilon\) \\
Model 6 &  \(\text{BC\_WS} = \beta _0 + \beta _1\cdot M\_U+ \beta _2\cdot \text{M\_V}+  \beta _3\cdot \text{Temperature} + \beta _4\cdot \text{Pressure}  + \epsilon\) \\
Model 7 &  \(\text{BC\_WS} = \beta _0 + f(M\_U)+ f(\text{M\_V})+ f(\text{Temperature}) + f(\text{Pressure})  + \epsilon\)
\end{tblr}    




\end{document}

The output from the code above looks like this: enter image description here

I tried to remove the, for example, row{2}={bg=brown!80!black,fg=white}, to remove the colouring, but I received the following error:

! Paragraph ended before \environment tblr  was complete.
<to be read again> 
                   \par 
l.113 

I want the output to look like this with footnotes about the stars(header row and first column are aligned centre, the remaining are aligned left): enter image description here


Solution

  • The error has nothing to do with the row colours, you are missing the amsmath package. Without this package you can't use the \text{...} macro.

    \documentclass{article}
    
    \usepackage{geometry}
    \usepackage{xcolor}
    \usepackage{tabularray}
    \usepackage{amsmath}
    
    \UseTblrLibrary{booktabs}
    
    \begin{document}
    
    \noindent\begin{tblr}{
      colspec={@{}l|[white]Xc@{}},
      hline{1,Z}={wd=1.2pt},
      hline{2}={wd=0.4pt},
      cell{2-Z}{2}={mode=imath}
    }
    Number  &  Model & Type\\
    Model 1 &  \text{BC\_WS} = \beta _0 + \beta _1\cdot {\text{M\_WS}} + \epsilon & LM*\\
    Model 2 &  \text{BC\_WS} = \beta _0 + f(\text{M\_WS}) + \epsilon& \\
    Model 3 &  \text{BC\_WS} = \beta _0 + \beta _1\cdot W\_WS+ \beta _2\cdot \text{\text{W\_Direction}}+  \beta _3\cdot \text{Temperature} + \beta _4\cdot \text{Pressure}  + \epsilon &  LM*\\
    Model 4 &  \text{BC\_WS} = \beta _0 + f(\text{M\_WS})+  f(\text{W\_Direction})+ f(\text{Temperature}) + f(\text{Pressure})  + \epsilon &\\
    Model 5 &  \text{BC\_WS} =\beta _0 + \beta _1\cdot (\text{M\_WS})+  f(\text{W\_Direction})+ f(\text{Temperature}) + f(\text{Pressure})  + \epsilon &\\
    Model 6 &  \text{BC\_WS} = \beta _0 + \beta _1\cdot M\_U+ \beta _2\cdot \text{M\_V}+  \beta _3\cdot \text{Temperature} + \beta _4\cdot \text{Pressure}  + \epsilon &  LM*\\
    Model 7 &  \text{BC\_WS} = \beta _0 + f(M\_U)+ f(\text{M\_V})+ f(\text{Temperature}) + f(\text{Pressure})  + \epsilon&\\
    \end{tblr}    
    
    \end{document}
    

    enter image description here