带列表的表格

带列表的表格

您将如何制作这种表格?您如何将数字与列表中的每个项目对齐?我试图将其用于\multirow{17}{*}列表,但似乎不起作用。

在此处输入图片描述

这是源代码:

\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

看看下面的代码是否给出了您所期望的结果:

\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}

在此处输入图片描述

补充: 在表格设计中使用booktabs水平线包(\toprule\midrule\bottomrule),\tabularx用于确定表格宽度和\siunoitx用于S列类型的包。在表格中引入了两个附加列。第一个是空的,可以\quad在代码中代替 ,第二个可以实现更好的数字格式或者

通过在表格中使用\sffamily字体,就像在问题中的图像中使用一样,将长列标题分成两行并减少表格列的间距1pt,可以使用正常大小的字体,这样更易​​于阅读:

在此处输入图片描述

MWE 的相关部分与 MWE 的第一个版本相比有所改变,并且还考虑了您在最终文档中使用的所有包,包括:

\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}

我使用最新的 MikTeX 测试了代码并且一切正常。

答案2

为了完整性,我添加了\usepackage[flushleft]{threeparttable}\begin{threeparttable}环境,以添加表格注释:

\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}

在此处输入图片描述

相关内容