我的表格格式有点小问题。当我运行以下代码时,表格的标题隐藏在表格内容下面。此外,cline
标题的底行(在 Risk1、Placebo 和 Risk 下面)下划线不正确。下面是一个通用示例
\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}
答案1
问题在于多行,它似乎没有做任何事情,所以我删除了它们(而且小页面也是不需要的)
\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}
如果您使用包中的命令,水平规则周围的间距将会得到改善booktabs
。
答案2
或多或少地此表生成器.还添加了一些使用该booktabs
包的规则。
顺便说一下,我想推荐一下siunitx
包裹用于处理表中的数字(和单位)。
\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}