我想在表格中显示测量结果,让查看者读出N
和的测量值$\Theta$
。下图显示了我的第一次尝试。虽然这没问题,但我想让它看起来更漂亮。首先,我如何让垂直线一直穿过?代码也附在下面。
\documentclass[a4paper,12pt]{article}
\usepackage{amsmath, amsmath, amssymb}
\usepackage[utf8x]{inputenc}
\usepackage{caption}
\begin{document}
\begin{table}[H]\centering
\caption{\label{tab2} FMM: profiling of subroutines}
\begin{tabular}{ll|cccccc}\toprule
& & \multicolumn{6}{c}{N} \\
~ & & 100 & 200 & 400 & 800 & 1600 & 3200 \\
\midrule\\
& 0.1 & 0.0008 & 0.0020 & 0.0056 & 0.0180 & 0.0556 & 0.1708 \\
& 0.2 & 0.0008 & 0.0016 & 0.0036 & 0.0108 & 0.0300 & 0.0792 \\
$\Theta$ & 0.4 & 0.0004 & 0.0012 & 0.0028 & 0.0060 & 0.0140 & 0.0344 \\
& 0.8 & 0.0004 & 0.0008 & 0.0016 & 0.0036 & 0.0064 & 0.0148 \\
& 1.6 & 0.0004 & 0.0004 & 0.0008 & 0.0028 & 0.0036 & 0.0080 \\ \hline
\end{tabular}
\end{table}
\end{document}
答案1
没有垂直线,没有居中,更友好的间距:
\documentclass[12pt]{article}
\usepackage{booktabs,leading}
\usepackage[utf8]{inputenc}
\usepackage[justification=raggedright,singlelinecheck=false]{caption}
\begin{document}
\begin{table}
\leading{16pt}
\caption{\label{tab2} FMM: profiling of subroutines}
\begin{tabular}{llllllll}
\cmidrule[0.08em](r){1-2}\cmidrule[0.08em]{3-8}
& & \textbf{N} \\
& & \textbf{100} & \textbf{200} & \textbf{400} & \textbf{800} & \textbf{1600} & \textbf{3200} \\
\cmidrule[0.08em](r){1-2}\cmidrule[0.08em]{3-8}
$\Theta$ & 0.1 & 0.0008 & 0.0020 & 0.0056 & 0.0180 & 0.0556 & 0.1708 \\
& 0.2 & 0.0008 & 0.0016 & 0.0036 & 0.0108 & 0.0300 & 0.0792 \\
& 0.4 & 0.0004 & 0.0012 & 0.0028 & 0.0060 & 0.0140 & 0.0344 \\
& 0.8 & 0.0004 & 0.0008 & 0.0016 & 0.0036 & 0.0064 & 0.0148 \\
& 1.6 & 0.0004 & 0.0004 & 0.0008 & 0.0028 & 0.0036 & 0.0080 \\
\cmidrule[0.05em](r){1-2}\cmidrule[0.05em]{3-8}
\end{tabular}
\end{table}
\end{document}
答案2
根本不要使用垂直线:
\documentclass[a4paper,12pt]{article}
\usepackage{amsmath, amsmath, amssymb}
\usepackage{caption}
\usepackage{ctable}
\usepackage{multirow}
\begin{document}
\begin{table}[H]\centering
\caption{\label{tab2} FMM: profiling of subroutines}
\begin{tabular}{lcccccc}\FL
\multirow{2}{*}{$\Theta$} & \multicolumn{6}{c}{N} \NN
\cmidrule(rl){2-7}
& 100 & 200 & 400 & 800 & 1600 & 3200 \ML
0.1 & 0.0008 & 0.0020 & 0.0056 & 0.0180 & 0.0556 & 0.1708 \\
0.2 & 0.0008 & 0.0016 & 0.0036 & 0.0108 & 0.0300 & 0.0792 \\
0.4 & 0.0004 & 0.0012 & 0.0028 & 0.0060 & 0.0140 & 0.0344 \\
0.8 & 0.0004 & 0.0008 & 0.0016 & 0.0036 & 0.0064 & 0.0148 \\
1.6 & 0.0004 & 0.0004 & 0.0008 & 0.0028 & 0.0036 & 0.0080
\LL
\end{tabular}
\end{table}
\end{document}