1

I am a beginner in Latex and I have searched through the internet but can't find a code that I can use to create the table below. Anyone know and easier way to go about it.

enter image description here]

1

Here are two MWEs you can start work with.

In example 1, which I recommend, I have used caption, booktabs and no vertical line.

Example 2, is a copy of your example. However, I have used fixed width columns to ensure that the six columns in the middle are approximately of the same width.

Example 1 – booktabs rules

enter image description here

\documentclass{article}
\usepackage{array, tabularx, booktabs}
\usepackage{geometry}

\usepackage[bf, font=bf]{caption}
\setlength{\extrarowheight}{1pt}
\renewcommand{\arraystretch}{1.2}
\setlength{\tabcolsep}{0.0em}

\begin{document}

\begin{table}
\small
\caption{Some key infant indicators in sub-Saharan Africa and other EHO regions}

\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}wl{3cm}*{6}{wc{1.3cm}}c}

\toprule
\bfseries Country &
\multicolumn{3}{c}{\bfseries Neonatal mortality rate*} &
\multicolumn{3}{c}{\bfseries Infant mortality rate*}   &
 \bfseries Low birthweight \\
\midrule
& 2009 & 2012 & 2016 & 2009 & 2012 & 2016 & 2007—2016\\
\midrule
\bfseries Malawi & 30   & 24   & 23 & 69 & 46 & 42 & 12 \\
Zambai           & 29   & 29   & 23 & 86 & 46 & 42 & 11 \\
Zimbabwe         & 30.5 & 27.8 & 22 & 58 & 48 & 38 & 11 \\
Botswana         & 22   & 29   & 26 & 43 & 41 & 33 & 13 \\
Kenya            & 27   & 27   & 23 & 55 & 49 & 36 &  8 \\
\midrule
\bfseries
WHO region       &      &      &    &    &    &    &    \\
African          & 36   & 32   & 28 & 80 & 63 & 53 & 14 \\
America          &  9   &  8   &  4 & 15 & 13 &  5 &  8 \\
Europe           &  7   &  6   &  2 & 12 & 10 &  3 &  7 \\
Asia             & 31   & 27   & 28 & 45 & 39 & 39 & 30 \\
\bottomrule
\multicolumn{6}{@{}l}{\small \emph{Source} Malawi data ans World Bank Development Indicators (2015)}\\\addlinespace[-1ex]
\multicolumn{6}{@{}l}{\footnotesize \emph{Note: *per 1000 live births }}\\

\end{tabular*}
\end{table}

\end{document}

Example 2 – Word-like

enter image description here

\documentclass{article}
\usepackage{array}
\usepackage{geometry}

\usepackage[bf, font=bf, hang]{caption}

\setlength{\extrarowheight}{1pt}
\renewcommand{\arraystretch}{1.2}
\setlength{\tabcolsep}{0.3em}

\begin{document}

\begin{table}

\caption{Some key infant indicators in sub-Saharan Africa and other EHO regions}

 \begin{tabular}{wl{2.4cm}|*{6}{wc{1.3cm}|}wc{2cm}}
\hline
\bfseries Country & \multicolumn{3}{c|}{\bfseries Neonatal mortality rate*} & \multicolumn{3}{c|}{\bfseries Infant mortality rate*} & \multicolumn{1}{c}{\bfseries Low birthweight} \\
\hline
& \multicolumn{1}{c}{2009} & \multicolumn{1}{c}{2012} & \multicolumn{1}{c|}{2016} 
& \multicolumn{1}{c}{2009} & \multicolumn{1}{c}{2012} & \multicolumn{1}{c|}{2016}
& 2007-2016\\
\hline
\bfseries Malawi & 30   & 24   & 23 & 69 & 46 & 42 & 12 \\\hline
Zambai           & 29   & 29   & 23 & 86 & 46 & 42 & 11 \\\hline
Zimbabwe         & 30.5 & 27.8 & 22 & 58 & 48 & 38 & 11 \\\hline
Botswana         & 22   & 29   & 26 & 43 & 41 & 33 & 13 \\\hline
Kenya            & 27   & 27   & 23 & 55 & 49 & 36 & 8  \\
\hline
\bfseries
WHO region       &      &      &    &    &    &    &    \\
African          & 36   & 32   & 28 & 80 & 63 & 53 & 14 \\
America          &  9   &  8   &  4 & 15 & 13 & 5  &  8 \\
Europe           &  7   &  6   &  2 & 12 & 10 & 3  &  7 \\
Asia             & 31   & 27   & 28 & 45 & 39 & 39 & 30 \\
\hline
\multicolumn{6}{@{}l}{\small \emph{Source} Malawi data ans World Bank Development Indicators (2015)}\\\addlinespace[-1ex]
\multicolumn{6}{@{}l}{\footnotesize \emph{Note: *per 1000 live births }}\\

\end{tabular}
\end{table}


\end{document}
0

You can use http://www.tablesgenerator.com/. It is the easiest way, I think.

Edit: You can paste existing table from Microsoft Excel, or import a CSV file. Then you immediately get a latex code which can be used as a starting point. For example, for the table above the following table is generated.

\begin{table}[]
\centering
\caption{Some key infant indicators in sub-Saharan Africa and other WHO regions}
\label{tab:my-table}
\resizebox{\textwidth}{!}{%
\begin{tabular}{@{}lccccccc@{}}
\toprule
\multicolumn{1}{c}{\multirow{2}{*}{Country}} & \multicolumn{3}{c}{\textbf{Neonatal mortality rate*}}        & \multicolumn{3}{c|}{\textbf{Infant mortality rate*}}         & \textbf{Low birthweight} \\ \cmidrule(l){2-8} 
\multicolumn{1}{c}{}                         & 2009        & 2012        & \multicolumn{1}{c|}{2016}        & 2009        & 2012        & \multicolumn{1}{c|}{2016}        & 2007-2016                \\ \midrule
\multicolumn{1}{l|}{\textbf{Malawi}}         & \textbf{30} & \textbf{24} & \multicolumn{1}{c|}{\textbf{23}} & \textbf{69} & \textbf{46} & \multicolumn{1}{c|}{\textbf{42}} & \textbf{12}              \\
\multicolumn{1}{l|}{Zambia}                  & 29          & 29          & \multicolumn{1}{c|}{23}          & 86          & 56          & \multicolumn{1}{c|}{44}          & 11                       \\
\multicolumn{1}{l|}{Zimbabwe}                & 30.5        & 27.8        & \multicolumn{1}{c|}{22}          & 58          & 48          & \multicolumn{1}{c|}{38}          & 11                       \\
\multicolumn{1}{l|}{Botswana}                & 22          & 29          & \multicolumn{1}{c|}{26}          & 43          & 41          & \multicolumn{1}{c|}{33}          & 13                       \\
\multicolumn{1}{l|}{Kenya}                   & 27          & 27          & \multicolumn{1}{c|}{23}          & 55          & 49          & \multicolumn{1}{c|}{36}          & 8                        \\ \midrule
\multicolumn{8}{l}{\textbf{WHO region}}                                                                                                                                                               \\
\multicolumn{1}{l|}{African}                 & 36          & 32          & \multicolumn{1}{c|}{28}          & 80          & 63          & \multicolumn{1}{c|}{53}          & 14                       \\
\multicolumn{1}{l|}{America}                 & 9           & 8           & \multicolumn{1}{c|}{4}           & 15          & 13          & \multicolumn{1}{c|}{5}           & 8                        \\
\multicolumn{1}{l|}{Europe}                  & 7           & 6           & \multicolumn{1}{c|}{2}           & 12          & 10          & \multicolumn{1}{c|}{3}           & 7                        \\
\multicolumn{1}{l|}{Asia}                    & 31          & 27          & \multicolumn{1}{c|}{28}          & 45          & 39          & \multicolumn{1}{c|}{39}          & 30                       \\ \midrule
\multicolumn{8}{l}{\begin{tabular}[c]{@{}l@{}}Source: Malawi data ans World Bank Development Indicators (2015)\\ Note: *per 1000 live births\end{tabular}}                                           
\end{tabular}%
}
\end{table}

enter image description here

  • 1
    +1 This looks interesting - I haven't seen this before. Ideally, you should give more detail in an answer as link-only answers are discouraged. – Andrew Jan 20 at 16:45

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.