我哪里做错了,导致单元格中出现 -c-?我只想bar
在那里显示文本“ ”。抱歉,我是新手
\documentclass{article}
\begin{table}
\centering
\rowcolors{1}{}{lightgray}
\begin{tabular}{|l|l|*{4}{wc{0.5\mycolwidth-2\tabcolsep}|}}
\hline
\multicolumn{1}{|c|}{} & {|c|}{} & \multicolumn{2}{c|}{All Sites} & \multicolumn{2}{c|}{NRH Sites} \\
\cline{3-6}
\multicolumn{1}{|c|}{foo} & {|c|}{} & Pre-QC & Post-QC & Pre-QC & Post-QC \\
\hline
A & 127 & 99.80 & 99.94 & 99.68 & 99.89 \\
B & 318 & 99.90 & 99.95 & 99.88 & 99.93 \\
C& 277 & 99.91 & 99.96 & 99.90 & 99.96 \\
\hline
\end{tabular}
\end{table}
\end{document}
答案1
这些位在做什么{|c|}{}
?你可能需要\multicolumn{1}{|c|}{}
,但你可以省略它。
\documentclass{article}
\usepackage{array}
\usepackage[table]{xcolor}
\newlength{\mycolwidth}
\setlength{\mycolwidth}{3cm}
\begin{document}
\begin{table}
\centering
\rowcolors{1}{}{lightgray}
\begin{tabular}{|l|l|*{4}{wc{\dimexpr0.5\mycolwidth-2\tabcolsep}|}}
\hline
& & \multicolumn{2}{c|}{All Sites} & \multicolumn{2}{c|}{NRH Sites} \\
\cline{3-6}
\multicolumn{1}{|c|}{foo} & & Pre-QC & Post-QC & Pre-QC & Post-QC \\
\hline
A & 127 & 99.80 & 99.94 & 99.68 & 99.89 \\
B & 318 & 99.90 & 99.95 & 99.88 & 99.93 \\
C& 277 & 99.91 & 99.96 & 99.90 & 99.96 \\
\hline
\end{tabular}
\end{table}
\end{document}
答案2
您是否想创建类似的东西?
观察发现{|c|}{}
碎片已经消失。
\documentclass{article}
\usepackage{array,calc}
\usepackage[table]{xcolor}
\newlength\mycolwidth
\setlength\mycolwidth{4cm} % or some other suitable value
\begin{document}
\begin{table}
\centering
\rowcolors{1}{}{lightgray}
\begin{tabular}{|l|l|*{4}{wc{0.5\mycolwidth-2\tabcolsep}|}}
\cline{3-6}
\multicolumn{2}{c|}{\cellcolor{white}} &
\multicolumn{2}{c|}{All Sites} & \multicolumn{2}{c|}{NRH Sites} \\
\hline
\multicolumn{1}{|c|}{foo} & \multicolumn{1}{c|}{} &
Pre-QC & Post-QC & Pre-QC & Post-QC \\
\hline
A & 127 & 99.80 & 99.94 & 99.68 & 99.89 \\
B & 318 & 99.90 & 99.95 & 99.88 & 99.93 \\
C & 277 & 99.91 & 99.96 & 99.90 & 99.96 \\
\hline
\end{tabular}
\end{table}
\end{document}