1

I have a small problem with my table formatting. When I run the following code, the headings of the table are hidden underneath the contents of the tables. Also the cline does not correctly underline the bottom row of the headings (underneath Risk1, Placebo and Risk). Take below a generic example

\documentclass[10pt,a4paper]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[margin=2.5cm]{geometry}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage[colaction]{multicol}
\usepackage{hyperref}
\usepackage{lineno} 
\usepackage{setspace}
\usepackage{multirow}
\usepackage{pdfpages}
\usepackage{lipsum}
\title{Table formatting}
\author{Unknown}

\begin{document}
\maketitle
\doublespacing

\begin{abstract}
    \lipsum[1-1]
\end{abstract}

\begin{multicols}{2}

\section{Introduction}      
\lipsum[1-1]

\section{Details}
\lipsum[1-1]
    \end{multicols}

\begin{table}[]
    \begin{minipage}{\columnwidth}
        \centering
        \caption{The table caption}
        \label{Table:1}
        \begin{tabular}{cccclclc}
            \multirow{2}{*}{} & \multirow{2}{*}{} & \multirow{2}{*}{Risk} & \multirow{2}{*}{95\% CI} & \multirow{2}{*}{} & \multirow{2}{*}{\begin{tabular}[c]{@{}l@{}}Risk\\ Placebo\end{tabular}} & \multirow{2}{*}{} &
            \multirow{2}{*}{\begin{tabular}[c]{@{}l@{}}Risk\\ Type A.\end{tabular}} \\
            \cline{3-3} \cline{6-6} \cline{8-8}
            \multirow{3}{*}{\begin{tabular}[c]{@{}l@{}}\textbf{Non-}\\ \textbf{Female}\end{tabular}} 
            & time1  & 10.4 & [ 8.6--12.5] & & 13.5 & & 18.7 \\
            & time2 & 25.9 & [23.8--28.1] & & 31.1 & & 42.8 \\
            & time3 & 41.2 & [37.5--45.3] & & 47.6 & & 65.3               
        \end{tabular}
    \end{minipage}
\end{table}

\begin{multicols}{2}
\section{Conclusion}
\lipsum[1-1]

\end{multicols}

\end{document}
  • Quick question: why do you use this mix of multirow and nested tabulars? I'm quite frankly are having a difficult time understanding how you want the result to look... – Holene Jan 27 '16 at 12:31
  • It was used formatted using an online table generator. Can you recommend another method to generate the answer proposed by @David_C – lukeg Jan 27 '16 at 12:36
4

The problem is the multirow, which did not appear to be doing anything so I deleted them (also the minipage was unneeded)

\begin{table}
        \centering
        \caption{The table caption}
        \label{Table:1}
        \begin{tabular}{cccclclc}
             & 
 &
 Risk & 
95\% CI &
  & 
\begin{tabular}[c]{@{}l@{}}Risk\\ Placebo\end{tabular} &
  &
  \begin{tabular}[c]{@{}l@{}}Risk\\ Type A.\end{tabular} \\
            \cline{3-3} \cline{6-6} \cline{8-8}
            \multirow{3}{*}{\begin{tabular}[c]{@{}l@{}}\textbf{Non-}\\ \textbf{Female}\end{tabular}} 
            & time1  & 10.4 & [ 8.6--12.5] & & 13.5 & & 18.7 \\
            & time2 & 25.9 & [23.8--28.1] & & 31.1 & & 42.8 \\
            & time3 & 41.2 & [37.5--45.3] & & 47.6 & & 65.3               
        \end{tabular}
\end{table}

enter image description here

The spacing around horizontal rules would be improved if you used the commands from the booktabs package.

3

More or less made with this Table Generator. Also added some rules using the booktabs package.

By the way, I'd like to recommend the siunitx package for handling numbers (and units) in the table.

\documentclass[]{scrartcl}

\usepackage{multirow,booktabs}

\begin{document}
\begin{table}
\centering
\caption{My caption}
\label{my-label}
\begin{tabular}{lllllllll}
\toprule
        &        & \multirow{2}{*}{Risk} & \multirow{2}{*}{95 \%} & Risk    & Risk  \\
        &        &                       &                        & Placebo & Type A \\
\midrule
\multirow{3}{*}{Non-Female}        & Time 1 & 10.4 & [ 8.6--12.5] & 13.5    & 18.7   \\
                  & Time 2 & 25.9 & [23.8--28.1] & 31.1    & 42.8   \\
                  & Time 3 & 41.2 & [37.5--45.3] & 47.6    & 65.3   \\
\bottomrule
\end{tabular}
\end{table}
\end{document}

enter image description here

  • Thanks a lot, but did you use siunitx in this example? – lukeg Jan 27 '16 at 12:46
  • 1
    As there is no \usepackage{siunitx} in my MWE: no. But I'd introduce it if I were you. For example you'd be able to write \SI{95}{\percent}, and should be able to get your numbers aligned around the decimal separator. – Holene Jan 27 '16 at 12:48

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.