1

enter image description here

Please help me merge the extra cells or column. I want to get ride of the empty column without separating my table into two.

\documentclass[a4paper,12p]{report}
\begin{document}
\begin{center}
    \begin{table}[h]
        \centering
        \caption{Initial conditions for HPAI infection in poultry only} 
        \small\addtolength{\tabcolsep}{-6pt}    
        \begin{tabular}{|*{12}{c|}}
            \hline 
            \multicolumn{3}{|c|}{Ghana} & \multicolumn{3}{|c|}{South Africa}  \\ 
            \multicolumn{3}{|c}{H5N1, 2007} & \multicolumn{3}{|c|}{H5N8, 2017} \\   \hline \cline{1-4}
            Initial condition &value  & reference & Initial condition &value  & reference \\ \hline
            $A_e$ & 6500 & Pelletier et al (2013) & $A_e$ & 285,000 & chikwati (2017)  \\ \hline
            $P_I$ & 11743 & OIE(2007) & $P_I$ & 24,000 & chikwati (2017)  \\ \hline
            $P_N$ & \num{2.0263e+5} & OIE(2017) & $P_N$ & 400,000 & schnirrring(2017)  \\ \hline    
            $P_s$ & 48052 & OIE(2007) & $P_s$ & 107,000 & OIE(2017) & \\ \hline
            S & 406,390 & wikipedia & S & \num{4.4442e+6} & www.gov.za  \\ \hline 
        \multicolumn{3}{|c|}{Zimbabwe} \\   
        \multicolumn{3}{|c|}{H5N8, 2017}\\  \hline
        \cline{1-3}
    Initial condition & value & reference\\ \hline
        $A_e$ & 140,000 &chikwati (2017) \\ \hline  
        $P_I$ & 7485 & pathfinder(2017)  \\ \hline
        $P_N$ & \num{2e+6} & Reuters(2017) \\ \hline    
         $P_s$ & 19172 & pathfinder(2017)\\ \hline
         S & \num{1.16706e+6} & www.Pindula.co.zw \\ \hline
        \end{tabular}
    \end{table}
\end{center}
\end{document}
  • 1
    Why not doing three separate tables? – egreg Sep 30 '17 at 9:06
3

First of all a couple of suggestions:

  1. don't enclose table in a center environment; use \centering after \begin{table}, instead;

  2. don't use the single [h] position specifier, but rather [htp];

  3. three separate tables seem better.

Here's how you can do it. Note that in \multicolumn the rules belong to the preceding column (except the first, of course). I added geometry in order to make the table fit.

\documentclass[a4paper,12pt]{report}
\usepackage[margin=1cm]{geometry}

\usepackage{siunitx}

\begin{document}

\begin{table}[htp]
\centering

\caption{Initial conditions for HPAI infection in poultry only} 

\small\addtolength{\tabcolsep}{-6pt}    

\begin{tabular}{|*{6}{c|}}
\hline 
\multicolumn{3}{|c|}{Ghana} & \multicolumn{3}{c|}{South Africa}  \\ 
\multicolumn{3}{|c|}{H5N1, 2007} & \multicolumn{3}{c|}{H5N8, 2017} \\
\hline
Initial condition & value  & reference & Initial condition &value  & reference \\
\hline
$A_e$ & 6500 & Pelletier et al (2013) & $A_e$ & 285,000 & chikwati (2017)  \\
\hline
$P_I$ & 11743 & OIE(2007) & $P_I$ & 24,000 & chikwati (2017)  \\
\hline
$P_N$ & \num{2.0263e+5} & OIE(2017) & $P_N$ & 400,000 & schnirrring(2017)  \\
\hline
$P_s$ & 48052 & OIE(2007) & $P_s$ & 107,000 & OIE(2017) & \\
\hline
$S$ & 406,390 & wikipedia & S & \num{4.4442e+6} & www.gov.za  \\
\hline 
\multicolumn{3}{|c|}{Zimbabwe} \\   
\multicolumn{3}{|c|}{H5N8, 2017}\\
\cline{1-3}
Initial condition & value & reference\\
\cline{1-3}
$A_e$ & 140,000 &chikwati (2017) \\
\cline{1-3}
$P_I$ & 7485 & pathfinder(2017)  \\
\cline{1-3}
$P_N$ & \num{2e+6} & Reuters(2017) \\
\cline{1-3}
$P_s$ & 19172 & pathfinder(2017)\\
\cline{1-3}
$S$ & \num{1.16706e+6} & www.Pindula.co.zw \\
\cline{1-3}
\end{tabular}

\end{table}

\end{document}

enter image description here

A different implementation:

\documentclass[a4paper,12pt]{report}
\usepackage[margin=1cm]{geometry}
\usepackage{siunitx,booktabs}

\begin{document}

\begin{table}[htp]
\centering

\caption{Initial conditions for HPAI infection in poultry only} 

\small
%\addtolength{\tabcolsep}{-3pt}

\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} c  c @{}}
\toprule
\begin{tabular}{@{} l c c @{}}
\multicolumn{3}{c}{Ghana, H5N1, 2007} \\
Initial condition & value  & reference \\
\midrule
$A_e$ & 6500 & Pelletier et al (2013) \\
$P_I$ & 11743 & OIE(2007) \\
$P_N$ & \num{2.0263e+5} & OIE(2017) \\
$P_s$ & 48052 & OIE(2007) \\
$S$   & 406,390 & wikipedia \\
\end{tabular}
&
\begin{tabular}{@{} l c c @{}}
\multicolumn{3}{c}{South Africa, H5N8, 2017} \\
Initial condition & value  & reference \\
\midrule
$A_e$ & 285,000 & chikwati (2017)  \\
$P_I$ & 24,000 & chikwati (2017)  \\
$P_N$ & 400,000 & schnirrring(2017)  \\
$P_s$ & 107,000 & OIE(2017) \\
$S$   & \num{4.4442e+6} & www.gov.za  \\
\end{tabular}
\\
\midrule
\begin{tabular}{@{} l c c @{}}
\multicolumn{3}{c}{Zimbabwe, H5N8, 2017}\\
Initial condition & value & reference\\
\midrule
$A_e$ & 140,000 &chikwati (2017) \\
$P_I$ & 7485 & pathfinder(2017)  \\
$P_N$ & \num{2e+6} & Reuters(2017) \\
$P_s$ & 19172 & pathfinder(2017)\\
$S$ & \num{1.16706e+6} & www.Pindula.co.zw \\
\end{tabular}
\\
\bottomrule
\end{tabular*}

\end{table}

\end{document}

enter image description here

1

i would design your table as follows:

  • remove first columns in second and third table
  • use S colum type from siunitx for columns with numbers
  • made consistent numbering format (i hope that my guess in mwe below is correct)
  • merge all three tables on one
  • increase page layout with use of `geometry package (with reducing margins)

enter image description here

\documentclass[a4paper,12p]{report}
\usepackage{geometry}
\usepackage{siunitx}
\usepackage{booktabs, makecell, tabularx}
\renewcommand\theadfont{\bfseries}
\usepackage{hyperref}
%-------------------------------- show page layout, only for test
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%


\begin{document}
    \begin{table}[h]
\caption{Initial conditions for HPAI infection in poultry only}
    \centering
    \small
    \setlength\tabcolsep{0pt}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
                c
           *{3}{S[table-format=7.0,
                      group-four-digits] l}
                }
    \toprule
    & \multicolumn{2}{c}{\thead{Ghana\\H5N1, 2007}}
        & \multicolumn{2}{c}{\thead{South Africa\\ H5N8, 2017}}
            & \multicolumn{2}{c}{\thead{Zimbabwe\\ H5N8, 2017}} \\
    \cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){6-7}
\makecell{Initial\\ cond.}
    & {value}   & reference
        & {value}   & reference
            & {value}   & reference                             \\
    \midrule
$A_e$   & 6500  & Pelletier et al (2013)
            & 285000   & chikwati (2017)
                & 140000    & chikwati (2017)                   \\
$P_I$   & 11743   & OIE(2007)
            & 24000  & chikwati (2017)
                & 140000    & chikwati (2017)                   \\
$P_N$ & 202630  & OIE(2017)
            & 400000    & schnirrring(2017)
                & 7485      & pathfinder(2017)                  \\
$P_s$ & 48052   & OIE(2007)
            & 107000    & OIE(2017)
                & 2000000   & Reuters(2017)                     \\
S     & 406390  & wikipedia
            & 44442000 & www.gov.za
                &   1167060 & \url{www.Pindula.co.zw}           \\
    \bottomrule
\end{tabular*}
    \end{table}
\end{document}

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.