2

My code and what I got,

\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{GROSS FISH OIL MARKET}}\\
    \multicolumn{5}{c}{\textbf{AS OF DECEMBER 31, 2014}}\\\hline    
    \rowcolor{LightCyan}  
     & & Proved & Proved & \\
    \rowcolor{LightCyan} 
    \multicolumn{1}{|c|}{\multirow{-1}{*}{Country}}
    &\multicolumn{1}{c|}{\multirow{-1}{*}{Company}}& COOKED & UNCOOKED & 
       \multicolumn{1}{c|}{\multirow{-1}{*}{Total Proved}}\\\cline{3-5}
    \rowcolor{LightCyan} 
    & & (M) & (M)& (M)\\\hline 
    A &  &60,143&36,388&96,531\\\hline
    \multicolumn{1}{|c|}{\multirow{2}{*}{KOREA}} &  &\multicolumn{1}{c|}{\multirow{2}{*}{645,039}} &\multicolumn{1}{c|}{\multirow{2}{*}{914592}}&\multicolumn{1}{c|}{\multirow{2}{*}{1,559,991}}\\
     Qurna & & & & \\\hline
     \multicolumn{1}{|c|}{\multirow{3}{*}{NPVC}}& I& 47,954 &7,724& 55,678 \\\cline{2-5}
     \multicolumn{1}{|c|}{} & K & 21,711 & 8,547  & 32,888  \\\cline{2-5}
     \multicolumn{1}{|c|}{} & L     & 833   & 0       & 843 \\\hline
     TOTAL F & & 52,740  & 937,611  & 1,412,351 \\\hline
\end{tabular}
\end{center}
\label{tab:multicol}
\end{table}


\end{document}

What I got is like below, Unwanted table

As you can see, first problem, after \cline{3-5} inserted after row, there was no cline or cline could be covered by rowcolor.

Second problem, textKoreaand Qurna were somehow overlapped, how to avoid this problem?

Appreciated on ony thoughts, comments and answers.

Regards,

Cheng

3

Here is a solution. I replaced \cline{3-5} with a \hhline commmand. I simplified the code with the makecell package, which allows line breaks in cells, and added some vertical padding of cells with thecellspace package. Finally I formatted and aligned the numbers with siunitx:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[letterpaper, top=0.5in, bottom=0.5in, left=1.55in, right=1.55in]{geometry}
\usepackage{multirow,array}
\usepackage{siunitx,booktabs,caption}
\sisetup{table-format=6.0,group-separator ={,}}
\usepackage{ragged2e}
\usepackage{hyperref}
\usepackage{hhline}
\usepackage[table]{xcolor}
\newcommand{\mc}[2]{\multicolumn{#1}{c}{#2}}
\definecolor{Gray}{gray}{0.85}
\definecolor{LightCyan}{rgb}{0.88,1,1}
\usepackage{makecell}
\renewcommand\theadfont{\bfseries}
\renewcommand\cellalign{bc}
\usepackage{cellspace}
\setlength\cellspacetoplimit{4pt}
\setlength\cellspacebottomlimit{4pt}

\begin{document}

\begin{table}[ht]
  \centering\
  \begin{tabular}{|Cc|Cc|S[table-format=5.0]|S|S[table-format=7.0]|}
    \multicolumn{5}{c}{\thead{GROSS FISH OIL MARKET \\ AS OF DECEMBER 31, 2014}}\\
    \hline
    \rowcolor{LightCyan}
    {Country} & {Company} & {\makecell{Proved \\COOKED}} & {\makecell{ Proved \\UNCOOKED}} &
    {\makecell{\\Total Proved}}\\        
    \hhline{>{\arrayrulecolor{LightCyan}}|>{\arrayrulecolor{LightCyan}}->{\arrayrulecolor{black}}|%
    >{\arrayrulecolor{LightCyan}}->{\arrayrulecolor{black}}|---}
    \rowcolor{LightCyan} & & {(M)} & {(M)} & {(M)} \\
    \hline
    A & & 60143 & 36388 & 96531 \\
    \hline
    \renewcommand\cellalign{cc}\makecell{KOREA \\Qurna} & & 645039 & 914592 & 1559991 \\
    \hline
    \multirowcell{3}[-0.67ex]{NPVC}& I & 47954 & 7724 & 55678 \\\cline{2-5}
   & K & 21711 & 8547 & 32888 \\\cline{2-5}
    & L & 833 & 0 & 843 \\\hline
    TOTAL F & & 52740 & 937611 & 1412351 \\\hline
  \end{tabular}
  \label{tab:multicol}
\end{table}

\end{document} 

enter image description here

| improve this answer | |
  • The white lines in the first row seems be annoying. Is there any way to make them disappear? – Hosein Rahnama Sep 22 '17 at 14:38
  • @H.R. Yes, I've modified the argument of `\hhline`. Please see the updated post. – Bernard Sep 22 '17 at 15:01
0

With recent versions of nicematrix (≥ 4.0 of 2020-05-08), we can acheive the result with the following code.

\documentclass{article}
\usepackage[left=1cm, right=1cm]{geometry}
\usepackage{siunitx}
\sisetup{table-format=6.0,group-separator ={,}}
\usepackage{xcolor}
\usepackage{makecell}
\renewcommand\cellalign{bc}
\usepackage{nicematrix}
\NiceMatrixOptions{cell-space-top-limit=4pt,cell-space-bottom-limit=4pt}

\begin{document}

\begin{table}[ht]
\centering\
\textbf{GROSS FISH OIL MARKET} \\ 
\textbf{AS OF DECEMBER 31, 2014} \\
\begin{NiceTabular}{CCS[table-format=5.0]SS[table-format=7.0]}%
       [hvlines,code-before = \rowcolor[rgb]{0.88,1,1}{1,2}]
Country \Block{2-1}{} & Company \Block{2-1}{} & {\makecell{Proved \\COOKED}} & {\makecell{ Proved \\UNCOOKED}} &
{\makecell{\\Total Proved}}\\        
& & {(M)} & {(M)} & {(M)} \\
A & & 60143 & 36388 & 96531 \\
\renewcommand\cellalign{cc}\makecell{KOREA \\Qurna} & & 645039 & 914592 & 1559991 \\
\Block{3-1}{NPVC}& I & 47954 & 7724 & 55678 \\
& K & 21711 & 8547 & 32888 \\
& L & 833 & 0 & 843 \\
TOTAL F & & 52740 & 937611 & 1412351 \\
\end{NiceTabular}
\end{table}

\end{document} 

The avantages are the following:

  • You don't have to use hhline, nor multirow, nor cellspace.
  • For the rules, you only have to use the key hvlines (no need of cline).
  • You don't have to define a color with a name since you specify the color only once.
  • There won't be artefacts in PDF viewers at some levels of zoom.

However, you will have to compile several times.

Ouput of the above code

| improve this answer | |
  • In this answer, since version 5.0 of nicematrix one must write c instead of C in the preamble of {NiceTabular} (but there is an option for backward compatibility). – F. Pantigny Jul 18 at 21:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.