我使用以下代码生成一个表:
\documentclass{article}
\usepackage{multirow}
\usepackage{array}
\begin{document}
\usepackage{multirow}
\usepackage{array}
\begin{table}[H]
\centering
\caption{Comparison of market prices, Black-Scholes prices and calibrated
Kou prices}
\begin{tabular}{>{\bfseries}c*{6}{c}}\toprule
\multirow{3.5}{*}{\bfseries Exercise Date} & & & \textbf{Strike Price}
& \textbf{}\\
\cmidrule(r{4pt}){2-6}
& & \multicolumn{3}{c}{\bfseries 4800} & \\
\cmidrule(r{4pt}){2-6}
& \textbf{Market Price} & \textbf{Black-Scholes Price}& \textbf{Kou Price} & \textbf{BS error} & \textbf{Kou error}\\
\midrule
18/11/2017 & x & x & x & x & x \\
6/12/2017 & x & x & x & x & x \\
1/05/2018 & x & x & x & x & x \\
12/06/2018 & x & x & x & x & x \\ \bottomrule
\end{tabular}
\begin{tabular}{>{\bfseries}c*{6}{c}}
& & \multicolumn{3}{c}{\bfseries 5600} & \\
\cmidrule(r{4pt}){2-6}
& \textbf{Market Price} & \textbf{Black-Scholes Price}& \textbf{Kou Price} & \textbf{BS error} & \textbf{Kou error}\\
\midrule
& x & x & x & x & x\\
& x & x & x & x & x\\
& x & x & x & x & x\\
& x & x & x & x & x\\ \bottomrule
\end{tabular}
\begin{tabular}{>{\bfseries}c*{6}{c}}
& & \multicolumn{3}{c}{\bfseries 5900} & \\
\cmidrule(r{4pt}){2-6}
& \textbf{Market Price} & \textbf{Black-Scholes Price}& \textbf{Kou Price} & \textbf{BS error} & \textbf{Kou error}\\
\midrule
& x & x & x & x & x\\
& x & x & x & x & x\\
& x & x & x & x & x\\
& x & x & x & x & x \\ \bottomrule
\end{tabular}
\end{table}
\end{document}
因此,第二和第三个表格需要与顶部表格对齐。此外,表格标题以及“锻炼日期”一词也需要居中(见上图)。
我怎样才能做到这一点?(也许设置一个固定的列宽度?)
答案1
为了使列对齐,最好将三个 合并tabular
为一个。这可以通过注释掉四行 来实现,\end{tabular}\begin{tabular} .. \end{tabular}\begin{tabular}
如下所示。您将只面临一个问题,即如何修剪\bottomrule
第 2 和第 3 个 的tabular
,这可以通过使用\cmidrule[\heavyrulewidth]{2-6}
而不是 来解决\bottomrule
。
\documentclass[10pt,a4paper]{article}
\usepackage{multirow,booktabs}
\usepackage{array}
\usepackage[margin=.8in]{geometry}
\begin{document}
\begin{table}
\centering
\caption{Comparison of market prices, Black-Scholes prices and calibrated
Kou prices}
\begin{tabular}{>{\bfseries}c*{6}{c}}\toprule
\multirow{3.5}{*}{\bfseries Exercise Date} & & & \textbf{Strike Price}
& \textbf{}\\
\cmidrule(r{4pt}){2-6}
& & \multicolumn{3}{c}{\bfseries 4800} & \\
\cmidrule(r{4pt}){2-6}
& \textbf{Market Price} & \textbf{Black-Scholes Price}& \textbf{Kou Price} & \textbf{BS error} & \textbf{Kou error}\\
\midrule
18/11/2017 & x & x & x & x & x \\
6/12/2017 & x & x & x & x & x \\
1/05/2018 & x & x & x & x & x \\
12/06/2018 & x & x & x & x & x \\ \bottomrule
%\end{tabular}
%\begin{tabular}{>{\bfseries}c*{6}{c}}
& & \multicolumn{3}{c}{\bfseries 5600} & \\
\cmidrule(rl){2-6}
& \textbf{Market Price} & \textbf{Black-Scholes Price}& \textbf{Kou Price} & \textbf{BS error} & \textbf{Kou error}\\
\cmidrule{2-6}
& x & x & x & x & x\\
& x & x & x & x & x\\
& x & x & x & x & x\\
& x & x & x & x & x\\ \cmidrule[\heavyrulewidth]{2-6}
%\end{tabular}
%\begin{tabular}{>{\bfseries}c*{6}{c}}
& & \multicolumn{3}{c}{\bfseries 5900} & \\
\cmidrule(rl){2-6}
& \textbf{Market Price} & \textbf{Black-Scholes Price}& \textbf{Kou Price} & \textbf{BS error} & \textbf{Kou error}\\
\cmidrule{2-6}
& x & x & x & x & x\\
& x & x & x & x & x\\
& x & x & x & x & x\\
& x & x & x & x & x \\ \cmidrule[\heavyrulewidth]{2-6}
\end{tabular}
\end{table}
\end{document}