5

How would you make this kind of table? How can you line the numbers with each item in the list? I'm trying to use \multirow{17}{*} for the list, but it doesn't seem to work.

enter image description here

This is the source code:

\documentclass[12pt]{report}
\usepackage[left=35mm, right=25mm, top=30mm, bottom=30mm]{geometry}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{enumitem,calc}
\usepackage{url}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{fixltx2e}
\usepackage{multirow}
\usepackage{indentfirst}
\usepackage{mathptmx}
\usepackage{textcomp}
\usepackage{fancyhdr}
\usepackage[super, nomove]{cite}

\sisetup{per-mode=symbol}
\newenvironment{tabitemize}[1][]
{\begin{itemize}[nosep,#1]}
{\end{itemize}}

\begin{document}

\begin{table}[htbp]
\caption{Systematic review of type 2 vs. type 1 diabetic pregnancies: maternal and fetal secondary outcomes}
\scriptsize
\begin{center}

\begin{tabular}{
>{\raggedright}p{.4\textwidth-2\tabcolsep-1.5\arrayrulewidth}
>{\raggedright\arraybackslash}p{.07\textwidth-2\tabcolsep-1.5\arrayrulewidth}
>{\raggedright\arraybackslash}p{.21\textwidth-2\tabcolsep-1.5\arrayrulewidth}
>{\raggedright\arraybackslash}p{.2\textwidth-2\tabcolsep-1.5\arrayrulewidth}
>{\raggedright\arraybackslash}p{.12\textwidth-2\tabcolsep-1.5\arrayrulewidth}
}
\hline
\textbf{Secondary outcomes}
&
\textbf{n}
&
\textbf{Heterogeneity (I\textsuperscript{2})(\%)}
&
\textbf{OR (95\% Cl)}
&
\textbf{\emph{P} value}\\
\hline
Maternal  &   &   &    &  \\
\quad Pregnancy-induced-hypertension &  9  &  48  &  0.87 (0.61--1.25)  &  NS\\
\quad Preeclampsia &  7  &  0  &  0.85 (0.61--1.17)  &  NS\\
\quad Hypoglycemic coma &  3  &  59.3  &  0.17 (0.03--1.11)  &  0.06\\
\quad Diabetic ketoacidosis &  5  &  0  &  0.09 (0.02--0.34)  &  \textless 0.001\\
\quad Cesarean section &  18  &  33.0  &  0.80 (0.68--0.94)  &  \textless 0.01\\
Fetal &    &    &   &  \\
\quad Miscarriages &  7  &  0  &  1.36 (0.98--1.90)  &  0.07\\
\quad Pregnancy terminations &  6  &  0  &  1.02 (0.48--2.16)  &  NS\\
\quad Preterm birth &  17  &  23.6  &  0.85 (0.70--1.03)  &  NS\\
\quad Small for gestational age newborns &  10  &  27.6  &  1.30 (0.80 --2.11)  &  NS\\
\quad Large for gestational age newborns &  14  &  14.5  &  0.98 (0.81--1.18)  &  NS\\
\quad Macrosomia &  6  &  23.0  &  1.02 (0.68--1.52)  &  NS\\
\quad MCM &  2  &  48  &  1.00 (0.27--3.70)  &  NS\\
\quad Hypoglycemia &  11  &  0  &  0.85 (0.62--1.16)  &  NS\\
\quad Jaundice &  7  &  31.0  &  0.82 (0.63--1.08)  &  NS\\
\quad Respiratory distress &  10  &  39.0  &  0.67 (0.41--1.09)  &  NS\\
\hline
\end{tabular}

\end{center}
\label{tab:review}
\end{table}

\end{document}
  • 1
    What list? The first column is left aligned and the entries, except Maternal and Fetal, are preceded by \quad. – egreg May 22 '16 at 17:54
  • Thanks @egreg, I haven't thought about that. I was using \begin{tabitemize} \item[] end{tabitemize} – Luigi May 22 '16 at 18:04
  • However, how do you align the numbers under the column "Heterogeneity" in the way shown? – Luigi May 22 '16 at 18:07
  • That's easy with siunitx. Can you add the “raw” code for a similar table so we don't have to type in the data? – egreg May 22 '16 at 18:08
3

See, if the following code gives what you expect:

\documentclass[12pt]{report}
\usepackage[left=35mm, right=25mm, top=30mm, bottom=30mm]{geometry}
\usepackage{booktabs,tabularx}
\usepackage{siunitx}


\begin{document}
    \begin{table}[htbp]
    \centering
\caption{Systematic review of type 2 vs. type 1 diabetic pregnancies: maternal and fetal secondary outcomes}
\footnotesize
\begin{tabularx}{\textwidth}{@{}
                l@{\quad}l
                S[table-format=2.0]
                S[table-format=2.1]
                r@{\,\,}X
                S[table-format=1.3,table-comparator = true]
                            @{}}
    \toprule
\multicolumn{2}{c}{\textbf{Secondary outcomes}}
    &   {\textbf{n}}
        &   \textbf{Heterogeneity (I\textsuperscript{2})(\%)}
            &   \multicolumn{2}{c}{\textbf{OR (95\% Cl)}}
                &   {\textbf{\emph{P} value}}            \\
    \midrule
\multicolumn{2}{@{}l}{Maternal}    
    &       &       &       &               &           \\
&   Pregnancy-induced-hypertension 
    &   9   &  48   & 0.87 & (0.61--1.25)  &  {NS}      \\
&   Preeclampsia 
    &   7   &  0    & 0.85 & (0.61--1.17)  &  {NS}      \\
&   Hypoglycemic coma 
    &   3   & 59.3  & 0.17 & (0.03--1.11)  &  0.06      \\
&   Diabetic ketoacidosis 
    &   5   &  0    & 0.09 & (0.02--0.34)  & <0.001     \\
&   Cesarean section 
    &  18   & 33.0  & 0.80 & (0.68--0.94)  & <0.01      \\
\multicolumn{2}{@{}l}{Fetal}  &   &   &   &   &            \\
&   Miscarriages 
    &   7   &  0    & 1.36 & (0.98--1.90)  &  0.07      \\
&   Pregnancy terminations 
    &   6   &  0    & 1.02 & (0.48--2.16)  &  {NS}      \\
&   Preterm birth 
    &  17   & 23.6  & 0.85 & (0.70--1.03)  &  {NS}      \\
&   Small for gestational age newborns 
    &  10   & 27.6  & 1.30 & (0.80 --2.11) &  {NS}      \\
&   Large for gestational age newborns 
    &  14   & 14.5  & 0.98 & (0.81--1.18)  &  {NS}      \\
&   Macrosomia 
    &  6    & 23.0  & 1.02 & (0.68--1.52)  &  {NS}      \\
&   MCM 
    &  2    &  48   & 1.00 & (0.27--3.70)  &  {NS}      \\
&   Hypoglycemia
    &  11   &   0   & 0.85 & (0.62--1.16)  &  {NS}      \\
&   Jaundice 
    &  7    & 31.0  & 0.82 & (0.63--1.08)  &  {NS}      \\
&   Respiratory distress 
    &  10   & 39.0  & 0.67 & (0.41--1.09)  &  {NS}      \\
    \bottomrule
\end{tabularx}
    \label{tab:review}
\end{table}
\end{document}

enter image description here

Addedundum: In table design are used packagesbooktabs for horizontal lines (\toprule, \midrule and \bottomrule), \tabularx for for determining table width and \siunoitx for S columntypes. IN table are intruduced two aditional columns. The first is emty and serve instead \quads in your code, with second is achieved better formatting of numbers OR.

With use \sffamily fonts in table, as it is used in image in your question, braking long column heads into two line and reducing table column separation for 1pt, it is possible use normal size fonts and with this make it more easy to read:

enter image description here

Relevant part of MWE, which is changed in comparison to the first version of MWE and also consider all packages, which you use in your final document, is:

\documentclass[12pt]{report}
\usepackage[left=35mm, right=25mm, top=30mm, bottom=30mm]{geometry}
\usepackage{booktabs,makecell,tabularx}

\renewcommand\theadfont{\bfseries\sffamily}
\newcommand\mcc[1]{\multicolumn{2}{c}{#1}}
\newcommand\mcl[1]{\multicolumn{2}{@{}l}{#1}}
\usepackage{siunitx}

% packages from final document but not used in table design
\usepackage{multirow}
\usepackage{enumitem,calc}
\usepackage{url}
\usepackage{fixltx2e}
\usepackage{indentfirst}
\usepackage{mathptmx}
\usepackage{textcomp}
\usepackage{fancyhdr}
\usepackage[super, nomove]{cite}

\sisetup{per-mode=symbol}
\newenvironment{tabitemize}[1][]
{\begin{itemize}[nosep,#1]}
{\end{itemize}}

\begin{document}
    \begin{table}[htbp]
    \centering
\caption{Systematic review of type 2 vs. type 1 diabetic pregnancies: maternal and fetal secondary outcomes}
    \sffamily
    \setlength\tabcolsep{5pt}
\begin{tabularx}{\textwidth}{@{}
                l@{\quad}l
                S[table-format=2.0]
                S[table-format=2.1]
                r@{\,\,}X
                S[table-format=1.3,table-comparator = true]
                            @{}}
    \toprule
\mcc{\thead[b]{Secondary outcomes}}
    &   {\thead[b]{n}}
        &   {\thead[b]{Heterogeneity\\ (I\textsuperscript{2})(\%)}}
            &   \mcc{\thead[b]{OR\\ (95\% Cl)}}
                &   {\thead[b]{\emph{P} value}}            \\
    \midrule
\mcl{Maternal}
...
\end{tabularx}
    \label{tab:review}
\end{table}
    \end{document}

I tested code with recent MikTeX and all works as expected.

  • Unfortunately I get the following error from the console..: (/usr/local/textlive/2015/texmf-dist/tex/latex/beamer/translator/dicts/translator-basic-dictionary/translator-basic-dictionary-English.dict)(/usr/local/texlive/2015/texmf-dist/tex/latex/siunitx/siunitx-abbreviations.cfg))* – Luigi May 22 '16 at 19:47
  • 1
    I use MikTeX 2.9, with recent packages version. I test my code again, and it works as expected. Sorry, I haven't any experiences with TeXLive, so don't any clue, what going wrong at you. I correct code formatting (\end{document} wasn't part of code). – Zarko May 22 '16 at 19:53
  • I have a problem.. if I put the code that you provided in an empty document, it works, while when I put it in my thesis (which has the same preamble as the code above, just with some more packages), I get the following error: LaTeX error: Not in outer par mode. See the LaTeX ... etc ... Type H<return> for immediate help. ... l.219 \begin{table}[htbp] ? – Luigi May 22 '16 at 19:59
  • 1
    Can you edit question and enumerate all package you use? I will check my MWE with them. Error is similar to errors, when \caption is out of table environment, but this is pure guessing. – Zarko May 22 '16 at 20:07
  • 1
    I add new example how to design your table. In it I use all your packages and I didn't got your error message. So, see again, how you include table into your code. Maybe with this you accidentally make some mistake. – Zarko May 22 '16 at 20:41
0

For completeness I add the \usepackage[flushleft]{threeparttable} and the \begin{threeparttable} environment, to add table notes:

\documentclass[12pt]{report}
\usepackage[left=35mm, right=25mm, top=30mm, bottom=30mm]{geometry}
\usepackage{booktabs,tabularx}
\usepackage{siunitx}
\usepackage[flushleft]{threeparttable}


\begin{document}
    \begin{table}[htbp]
        \begin{threeparttable}
    \centering
\caption{Systematic review of type 2 vs. type 1 diabetic pregnancies: maternal and fetal secondary outcomes}
\footnotesize
\begin{tabularx}{\textwidth}{@{}
            l@{\quad}l
            S[table-format=2.0]
            S[table-format=2.1]
            r@{\,\,}X
            S[table-format=1.3,table-comparator = true]
                        @{}}
    \toprule
\multicolumn{2}{c}{\textbf{Secondary outcomes}}
    &   {\textbf{n}}
        &   \textbf{Heterogeneity (I\textsuperscript{2})(\%)}
            &   \multicolumn{2}{c}{\textbf{OR (95\% Cl)}}
                &   {\textbf{\emph{P} value}}            \\
    \midrule
\multicolumn{2}{@{}l}{Maternal}    
    &       &       &       &               &           \\
&   Pregnancy-induced-hypertension 
    &   9   &  48   & 0.87 & (0.61--1.25)  &  {NS}      \\
&   Preeclampsia 
    &   7   &  0    & 0.85 & (0.61--1.17)  &  {NS}      \\
&   Hypoglycemic coma 
    &   3   & 59.3  & 0.17 & (0.03--1.11)  &  0.06      \\
&   Diabetic ketoacidosis 
    &   5   &  0    & 0.09 & (0.02--0.34)  & <0.001     \\
&   Cesarean section 
    &  18   & 33.0  & 0.80 & (0.68--0.94)  & <0.01      \\
\multicolumn{2}{@{}l}{Fetal}  &   &   &   &   &            \\
&   Miscarriages 
    &   7   &  0    & 1.36 & (0.98--1.90)  &  0.07      \\
&   Pregnancy terminations 
    &   6   &  0    & 1.02 & (0.48--2.16)  &  {NS}      \\
&   Preterm birth 
    &  17   & 23.6  & 0.85 & (0.70--1.03)  &  {NS}      \\
&   Small for gestational age newborns 
    &  10   & 27.6  & 1.30 & (0.80 --2.11) &  {NS}      \\
&   Large for gestational age newborns 
    &  14   & 14.5  & 0.98 & (0.81--1.18)  &  {NS}      \\
&   Macrosomia 
    &  6    & 23.0  & 1.02 & (0.68--1.52)  &  {NS}      \\
&   MCM 
    &  2    &  48   & 1.00 & (0.27--3.70)  &  {NS}      \\
&   Hypoglycemia
    &  11   &   0   & 0.85 & (0.62--1.16)  &  {NS}      \\
&   Jaundice 
    &  7    & 31.0  & 0.82 & (0.63--1.08)  &  {NS}      \\
&   Respiratory distress 
    &  10   & 39.0  & 0.67 & (0.41--1.09)  &  {NS}      \\
    \bottomrule
\end{tabularx}
    \label{tab:review}
    \begin{tablenotes}
        \footnotesize
        \item This is where authors provide additional information about
  the data, including whatever notes are needed.
       \end{tablenotes}
    \end{threeparttable}
\end{table}
\end{document}

enter image description here

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.