对多列中的整行进行着色

对多列中的整行进行着色
\documentclass[a4paper, twocolumn, 12pt, notitlepage, nofootinbib]{revtex4-1}
\usepackage[top=25mm,bottom=25mm,left=25mm,right=25mm]{geometry}
\usepackage[table]{xcolor}
\usepackage{amsmath,amsfonts,amsthm,bm} 
\usepackage{physics}
\usepackage[version=3]{mhchem}
\usepackage{graphicx}
\usepackage{listings}
\usepackage{gensymb}
\usepackage{epstopdf}
\usepackage{placeins}
\usepackage{booktabs}
\usepackage{colortbl}
\usepackage{multirow}
\usepackage{siunitx}
\usepackage{url}
\linespread{1.5}
\setlength{\columnsep}{6mm}
\usepackage{setspace}

\begin{document} 

%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{table}[]

\centering
\begin{tabular}{ccc|cc}
\hline
\multicolumn{2}{c@{\quad}}{PMLG-5}    
&&                                           
\multicolumn{2}{c}{PMLG-9} \\          
\textit{n} & {$\bar{n}$} && \textit{n} & {$\bar{n}$} \\
\hline
\rowcolor{lightgray}
~168.46~ & ~348.46 &  & ~168.46~ & ~348.46~ \\
~126.9 ~ & ~306.90 &  & ~145.37~ & ~325.37~ \\
\rowcolor{lightgray}
~85.35 ~ & ~265.34 &  & ~122.28~ & ~302.28~ \\
~43.78 ~ & ~223.78 &  & ~99.19~  & ~279.19~ \\
~2.22  ~ & ~182.22 &  & ~76.10~  & ~256.11~ \\
~182.22~ & ~2.22   &  & ~53.02~  & ~233.02~ \\
~223.78~ & ~43.78  &  & ~29.93~  & ~209.93~ \\
~265.34~ & ~85.34  &  & ~6.84~   & ~186.84~ \\
~306.9 ~ & ~126.90 &  & ~343.75~ & ~163.75~ \\
~348.46~ & ~168.46 &  & ~163.75~ & ~343.75~ \\
         &          &  & ~186.84~ & ~6.84~   \\
         &          &  & ~209.93~ & ~29.93~  \\
         &          &  & ~233.02~ & ~53.00~  \\
         &          &  & ~256.11~ & ~76.11~  \\
         &          &  & ~279.19~ & ~99.19~  \\
         &          &  & ~302.28~ & ~122.28~ \\
         &          &  & ~325.37~ & ~145.37~ \\
         &          &  & ~348.46~ & ~168.46~ \\
\hline

\end{tabular}

\end{table}

\end{document}

当尝试为包含数字的整行着色时,它只会为数值着色,而不是整行。我该如何让它突出显示整行?

在此处输入图片描述

答案1

看起来还行——可能在你的序言里有一些东西

在此处输入图片描述

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{colortbl}% http://ctan.org/pkg/colortbl
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\usepackage{xcolor}% http://ctan.org/pkg/xcolor
\usepackage{booktabs}
\begin{document}

\begin{table}[]

\centering
\begin{tabular}{ccc|cc}
\hline
\multicolumn{2}{c@{\quad}}{PMLG-5}    
&&                                           
\multicolumn{2}{c}{PMLG-9} \\          
\textit{n} & {$\bar{n}$} && \textit{n} & {$\bar{n}$} \\
\hline
\rowcolor{yellow}
~168.46~ & ~348.46 &  & ~168.46~ & ~348.46~ \\
~126.9 ~ & ~306.90 &  & ~145.37~ & ~325.37~ \\
\rowcolor{green}
~85.35 ~ & ~265.34 &  & ~122.28~ & ~302.28~ \\
~43.78 ~ & ~223.78 &  & ~99.19~  & ~279.19~ \\
~2.22  ~ & ~182.22 &  & ~76.10~  & ~256.11~ \\
~182.22~ & ~2.22   &  & ~53.02~  & ~233.02~ \\
~223.78~ & ~43.78  &  & ~29.93~  & ~209.93~ \\
~265.34~ & ~85.34  &  & ~6.84~   & ~186.84~ \\
~306.9 ~ & ~126.90 &  & ~343.75~ & ~163.75~ \\
~348.46~ & ~168.46 &  & ~163.75~ & ~343.75~ \\
         &          &  & ~186.84~ & ~6.84~   \\
         &          &  & ~209.93~ & ~29.93~  \\
         &          &  & ~233.02~ & ~53.00~  \\
         &          &  & ~256.11~ & ~76.11~  \\
         &          &  & ~279.19~ & ~99.19~  \\
         &          &  & ~302.28~ & ~122.28~ \\
         &          &  & ~325.37~ & ~145.37~ \\
         &          &  & ~348.46~ & ~168.46~ \\
\hline

\end{tabular}

\end{table}
\end{document}

相关内容