首先,我的代码,
\documentclass{article}
\usepackage{ragged2e}
\usepackage[utf8]{inputenc}
\usepackage[letterpaper, top=0.5in, bottom=0.5in, left=1.55in, right=1.55in]{geometry}
\usepackage{multirow,array,varwidth,spreadtab,caption}
\usepackage[norule]{footmisc}
\usepackage{pythontex}
\usepackage{siunitx,booktabs,caption}
\usepackage{ragged2e}
\usepackage{layout}
\usepackage{xtab}
\usepackage{float}
\usepackage{gensymb}
\usepackage{hyperref}
\usepackage[some,bottom]{background}
\usepackage{enumerate}
\usepackage{fancyhdr}
\usepackage{color, colortbl}
\usepackage{xcolor}
\usepackage{multicol}
\usepackage{indentfirst}
\newcommand{\mc}[2]{\multicolumn{#1}{c}{#2}}
\definecolor{Gray}{gray}{0.85}
\definecolor{LightCyan}{rgb}{0.88,1,1}
\begin{document}
\begin{table}[ht]
\begin{center}
\begin{tabular}{|c|c|c|c|c|}
\multicolumn{5}{c}{\textbf{NET ENTITLEMENT FISH OIL MARKETS}}\\
\multicolumn{5}{c}{\textbf{AS OF DECEMBER 31, 2019}}\\\hline
\rowcolor{LightCyan}
\multicolumn{1}{|c|}{\multirow{2}{*}{Country}}&\multicolumn{1}{c|}{\multirow{2}{*}{Company}}&Proved Cooked&Proved Uncooked&Total Proved\\
\rowcolor{LightCyan}
\multicolumn{1}{|c|}{}&\multicolumn{1}{c|}{}&(T)&(T)&(T)\\\hline
ChUAN& \pyc{print("{}".format(row[0]))} &51,574&31,202&82,776\\\hline
IraW-West POINT & & 9,656 &57,981&67,637\\\hline
\multicolumn{1}{|c|}{\multirow{3}{*}{KAZSLSKDE}}& PKKR& 32,129 &5,174& 37,304 \\\cline{2-5}
\multicolumn{1}{|c|}{}&KOLKOL&9,718&3,447&13,165\\\cline{2-5}
\multicolumn{1}{|c|}{}&PKPK&424&0&424\\\hline
TOTAL CNNNO & & 103,501 & 97,804 & 201,306\\\hline
\end{tabular}
\end{center}
\label{tab:multicol}
\end{table}
\end{document}
我得到的结果如下,
第二行的颜色显然不仅遮挡了"Country"
和"Company"
,还遮挡了"|"
前两行的。
我该如何摆脱这个问题?非常感谢任何评论和帮助。
问候,郑
答案1
表格是逐行构建的。\multirow{2}
将内容放在当前行和下一行中。但下一行尚未绘制,并将覆盖粘贴在此行中的文本。
更好的方法是使用\multirow{-2}
在下面的行中打印当前行和上面已经设置好的行。
\begin{tabular}{|c|c|c|c|c|}
\multicolumn{5}{c}{\textbf{NET ENTITLEMENT FISH OIL MARKETS}}\\
\multicolumn{5}{c}{\textbf{AS OF DECEMBER 31, 2019}}\\\hline
\rowcolor{LightCyan}
&&Proved
Cooked&Proved Uncooked&Total Proved\\
\rowcolor{LightCyan}
\multicolumn{1}{|c|}{\multirow{-2}{*}{Country}}
&\multicolumn{1}{c|}{\multirow{-2}{*}{Company}}
&(T)&(T)&(T)\\\hline
ChUAN& \pyc{print("{}".format(row[0]))} &51,574&31,202&82,776\\\hline
IraW-West POINT & & 9,656 &57,981&67,637\\\hline
\multicolumn{1}{|c|}{\multirow{3}{*}{KAZSLSKDE}}& PKKR& 32,129 &5,174&
37,304 \\\cline{2-5}
\multicolumn{1}{|c|}{}&KOLKOL&9,718&3,447&13,165\\\cline{2-5}
\multicolumn{1}{|c|}{}&PKPK&424&0&424\\\hline
TOTAL CNNNO & & 103,501 & 97,804 & 201,306\\\hline
\end{tabular}
评论:
\centering
避免table
了由环境设置的额外垂直空间center
。...
答案2
另一个解决方案是使用makecell
包,它允许在单元格内换行,并允许使用通用格式。此外,行数也更少。我删除了加载color
,因为您加载xcolor
,并添加了table
选项?我使用包格式化了数字siunitx
。最后,由于我没有pythontex
安装,我不得不注释掉使用它的行:
\documentclass{article}
\usepackage{ragged2e}
\usepackage[utf8]{inputenc}
\usepackage[letterpaper, top=0.5in, bottom=0.5in, left=1.55in, right=1.55in]{geometry}
\usepackage{multirow,array,varwidth,spreadtab,caption}
\usepackage[norule]{footmisc}
%\usepackage{pythontex}
\usepackage{siunitx,booktabs,caption}
\usepackage{ragged2e}
\usepackage{layout}
\usepackage{xtab}
\usepackage{float}
\usepackage{gensymb}
\usepackage{hyperref}
\usepackage[some,bottom]{background}
\usepackage{enumerate}
\usepackage{fancyhdr}
\usepackage{colortbl}
\PassOptionsToPackage{xcolor}{table}
\usepackage{multicol}
\usepackage{indentfirst}
\usepackage{makecell}
\renewcommand\theadfont{\bfseries}
\newcommand{\mc}[2]{\multicolumn{#1}{c}{#2}}
\definecolor{Gray}{gray}{0.85}
\definecolor{LightCyan}{rgb}{0.88,1,1}
\usepackage{siunitx}
\sisetup{table-format=6.0,group-separator ={,}}
\begin{document}
\begin{table}[ht]
\centering\setlength\extrarowheight{2pt}
\label{tab:multicol}
\begin{tabular}{|c|c|S|S[table-format=5.0]|S|}
\multicolumn{5}{c}{\thead{NET ENTITLEMENT FISH OIL MARKETS\\ AS OF DECEMBER 31, 2019}}\\
\hline%
\rowcolor{LightCyan}
Country & Company & {\makecell{Proved Cooked\\T}} & {\makecell{Proved Uncooked\\T}}& {\makecell{Total Proved \\T}}\\
\hline
% ChUAN& \pyc{print("{}".format(row[0]))} &51,574&31,202&82,776\\\hline
IraW-West POINT & & 9656 &57981&67 637\\\hline
\multicolumn{1}{|c|}{\multirow{3}{*}{KAZSLSKDE}}& PKKR& 32129 & 5174 & 37304 \\\cline{2-5}
\multicolumn{1}{|c|}{}&KOLKOL&9718 & 3447 & 13165\\\cline{2-5}
\multicolumn{1}{|c|}{}&PKPK& 424 & 0& 424\\\hline
TOTAL CNNNO & & 103501 & 97804 & 201306\\\hline
\end{tabular}
\end{table}
\end{document}