是否可以在 xltabular 环境中为行着色(每行使用不同的颜色)?

是否可以在 xltabular 环境中为行着色(每行使用不同的颜色)?

我想为表格行中包含的文本着色,但每行使用不同的颜色。我该怎么做?下面,我展示了我的最少代码。

\documentclass[12pt, article]{memoir}
% Packages
\usepackage[T1]{fontenc}
\usepackage[brazilian]{babel}
\usepackage{geometry}
     \geometry{a4paper, hdivide = {30mm, 160mm, 20mm}, vdivide = {30mm, 247mm, 20mm}}
\usepackage{xltabular}
\usepackage{multirow}
\usepackage{bigstrut}
\usepackage{booktabs}
\usepackage{graphicx}
     \graphicspath{{../imagens/}}
\usepackage[table]{xcolor}

% First row in table one
\def\mil{\rotatebox{90}{Millions}}
\def\hth{\rotatebox{90}{Hundred thousands}}
\def\tth{\rotatebox{90}{Ten thousands}}
\def\tho{\rotatebox{90}{Thousands}}
\def\hun{\rotatebox{90}{Hundreds}}
\def\one{\rotatebox{90}{Ones}}
\def\pnt{\rotatebox{90}{and}}
\def\ten{\rotatebox{90}{Tenths}}
\def\hus{\rotatebox{90}{Hundredths}}
\def\ths{\rotatebox{90}{Thousandths}}
\def\tts{\rotatebox{90}{Ten thousandths}}
\def\hts{\rotatebox{90}{Hundred thousandths}}
\def\mls{\rotatebox{90}{Millionths}}
\def\tms{\rotatebox{90}{Ten millionths}}
\def\hms{\rotatebox{90}{Hundred millionths}}


\begin{document}
     \begin{xltabular}{\linewidth}{ccccccccccccccccccccc}
          \toprule
          \mil & \hth & \tth & \tho & \hun & \one & \pnt & \ten & \hus & \ths & \tts & \hts & \mls & \tms & \hms &&&&& \\
          \midrule\rowcolor{blue}
          & & & & 3 & 6 & . & 5 & 7 &  &  &  &  &  & & & & & & \\
          \midrule%\rowstyle{\color{green}}
          \multicolumn{15}{c}{thirty-six and fifty-seven hundredths.}\\
          \midrule
          & & & &  & 4 & . & 6 & 0 & 3 &  &  &  &  & & & & & & \\
          \midrule
          \multicolumn{15}{c}{four and six hundred three thousandths}\\
          \midrule
          & & & 1 & 2 & 4 & . & 1 & 2 & 3 &  &  &  &  & & & & & & \\
          \midrule
          \multicolumn{16}{c}{One hundred twenty four and one hundred twenty three thousandths}\\
          \midrule
          & & &  & 1 & 2 & . & 0 & 0 & 3 & 2 & 1 & 4 &  & & & & & & \\
          \midrule
          \multicolumn{15}{c}{Twelve three thousand two hundred fourteen millionths.}\\
          \midrule
          & & &  &  & 0 & . & 3 & 2 & 6 & 3 &  &  &  & & & & & & \\
          \midrule
          \multicolumn{15}{c}{text}\\
          \bottomrule\\
     \end{xltabular}
       
      \end{document}

答案1

尝试这个

\usepackage[table]{xcolor}
 
% Table code
{
    \rowcolors{2}{green!25}{green!75}
    \begin{tabular}{ccc}
        \hline
        \rowcolor{gray}Header & Header            & Header \\
        1                     & 2                 & 3      \\
        4                     & \cellcolor{gray}5 & 6      \\
        7                     & 8                 & 9      \\
        \hline
    \end{tabular}
}

相关内容