表格颜色问题——如何使某一行的单元格完全填充一种颜色使的两个单元格中间没有缝隙?

2019-08-29 18:10发布

[图]如题。我在用latex画带有颜色的表格时遇到一个问题,代码如下\documentclass[UTF8,12pt,a4paper]{ctexart} \usepackage[left=3.18cm,ri...

如题。我在用latex画带有颜色的表格时遇到一个问题,代码如下

\documentclass[UTF8,12pt,a4paper]{ctexart}
\usepackage[left=3.18cm,right=3.18cm,top=2.54cm,bottom=2.54cm]{geometry}
\usepackage[table]{xcolor}
\usepackage{booktabs}
\usepackage{bigstrut}
\usepackage{multirow}
\begin{document}
    \section*{}
% Table generated by Excel2LaTeX from sheet 'Sheet1'
\begin{table}[htbp]
  \centering
  \caption{Add caption}
    \begin{tabular}{ccc}
    \toprule
          & \multicolumn{2}{c}{\textbf{Specific Heats}} \\
\cmidrule{2-3}          & \multicolumn{1}{l}{c(J/kg$\cdot$K)} & \multicolumn{1}{l}{C(J/mol$\cdot$K)} \\
    \midrule
    Aluminum & 900   & 24.3 \\
    \rowcolor[rgb]{ .816,  .808,  .808} Copper & 385   & 24.4 \\
    Gold  & 130   & 25.6 \\
    \rowcolor[rgb]{ .816,  .808,  .808} Steel & 450   & 25 \\
    Lead  & 130   & 26.8 \\
    \rowcolor[rgb]{ .816,  .808,  .808} Water & 4190  & 75.4 \\
    Ice(-10${^\circ}$C) & 2100  & 38 \\
    \bottomrule
    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%


\end{document}

Snipaste_2019-08-29_18-03-22.png


生成表格如图,请问怎样才能使某一行无缝填充?


2条回答
OsbertWang - 目前是一名 LaTeX 学徒
2019-08-29 19:28 .采纳回答

我运行了一遍,没发现有问题。

有一个括号,你打成了中文的。

\documentclass[UTF8,12pt,a4paper]{ctexart}
\usepackage[left=3.18cm,right=3.18cm,top=2.54cm,bottom=2.54cm]{geometry}
\usepackage[table]{xcolor}
\usepackage{booktabs}
\usepackage{bigstrut}
\usepackage{multirow}
\begin{document}
  \begin{table}[htbp]
    \centering
    \caption{Add caption}\label{tab:addlabel}
    \begin{tabular}{ccc}
      \toprule
      & \multicolumn{2}{c}{\textbf{Specific Heats}} \\
      \cmidrule{2-3} & \multicolumn{1}{l}{c(J/kg$\cdot$K)} & \multicolumn{1}{l}{C(J/mol$\cdot$K)} \\
      \midrule
      Aluminum & 900 & 24.3 \\
      \rowcolor[rgb]{ .816,  .808,  .808} Copper & 385 & 24.4 \\
      Gold  & 130 & 25.6 \\
      \rowcolor[rgb]{ .816,  .808,  .808} Steel & 450 & 25 \\
      Lead  & 130 & 26.8 \\
      \rowcolor[rgb]{ .816,  .808,  .808} Water & 4190 & 75.4 \\
      Ice(-10${^\circ}$C) & 2100 & 38 \\
      \bottomrule
    \end{tabular}
  \end{table}
\end{document}


一周热门 更多>