我想在 中绘制缺失的垂直线tabular
。我认为\multirow{2}{*}{}
这会阻止绘制表格的垂直线。
我的代码:
\documentclass{article}
\usepackage[a4paper,margin=1in,landscape]{geometry}
\usepackage{makecell}
\usepackage{multirow}
\usepackage{booktabs}
\begin{document}
\begin{center}
\begin{table*}[!t] %
\centering
\caption{Results ...}
\begin{tabular}{|c|c|c|c|c|c|c|c|c|}
\hline
\textbf{Test} & \multicolumn{2}{c|}{Workflow} & Method
& \multirow{2}{*}{\makecell{Completion \\ Time (min)}}
& \multirow{2}{*}{\makecell{Gas Used for \\
\textit{submitJob} (gas)}}
& \multirow{2}{*}{\makecell{Gas Used for \\
\textit{processPayment} (gas)}}
& \multirow{2}{*}{\makecell{Actual/Complete \\ Cost
(\textit{Cent})}}
& \multirow{2}{*}{\makecell{Failed}} \\
\cmidrule(lr){2-3}
& $|V|$ & $|E|$ \\
\hline
$T_1$ & 16 & 28 & ALGO & 27 & 1722983 & 1942770 & 0.827/0.827 & 0 \\ \hline
\end{tabular}
\end{table*}
\end{center}
\end{document}
输出:
答案1
您可以使用nicematrix
该hvlines
选项。多行和多列单元格的命令都是\Block
。
请记住,这\Block
不会导致单元格被跳过,因此&&
在工作流和方法单元格之间是必要的。另外不要忘记编译两次。
该线\NiceMatrixOptions{cell-space-limits = 2pt}
是可选的,它在行之间创建一些额外的垂直空间。
\documentclass{article}
\usepackage[a4paper,margin=1in,landscape]{geometry}
\usepackage{nicematrix}
\begin{document}
\begin{center}
\begin{table*}[!t] %
\centering
\caption{Results ...}
\NiceMatrixOptions{cell-space-limits = 2pt}
\begin{NiceTabular}{ccccccccc}[hvlines]
\Block{2-1}{\textbf{Test}} & \Block{1-2}{Workflow} && \Block{2-1}{Method} & \Block{2-1}{Completion\\Time (min)}
& \Block{2-1}{Gas Used for\\ \textit{submitJob} (gas)}
& \Block{2-1}{Gas Used for\\ \textit{processPayment} (gas)}
& \Block{2-1}{Actual/Complete\\ Cost (\textit{Cent})}
& \Block{2-1}{Failed}\\
& $|V|$ & $|E|$ \\
$T_1$ & 16 & 28 & ALGO & 27 & 1722983 & 1942770 & 0.827/0.827 & 0
\end{NiceTabular}
\end{table*}
\end{center}
\end{document}
答案2
如果你要使用软件包的线条绘制宏booktabs
,请不要使用垂直线。无论如何都不要。
landscape
请注意,如果在加载包时指定选项geometry
,则整个文档将以横向模式排版。无需\begin{landscape}
和\end{landscape}
。
\documentclass{article}
\usepackage[a4paper,margin=1in,landscape]{geometry}
\usepackage{booktabs,array,calc}
\newcommand\mytab[1]{\smash{\begin{tabular}[t]{@{} c @{}} #1 \end{tabular}}}
\newlength\mylen
\setlength\mylen{\widthof{Workflow}-4\tabcolsep}
\begin{document}
\begin{table}[h]
\centering
\caption{Results \dots}
\smallskip
\begin{tabular}{@{} *{2}{wc{\mylen}} *{7}{c} @{}}
\toprule
Test
& \multicolumn{2}{@{}c@{}}{Workflow}
& Method
& \mytab{Completion \\ Time (min)}
& \mytab{Gas used for \\ \textit{submitJob} (gas)}
& \mytab{Gas used for \\ \textit{processPayment} (gas)}
& \mytab{Actual/Complete \\ Cost (\textit{Cent})}
& Failed \\
\cmidrule(lr){2-3}
& $V$ & $E$ \\
\midrule
$T_1$ & 16 & 28 & ALGO & 27 & 1722983 & 1942770 & 0.827/0.827 & 0 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案3
如果没有其他方法可行,我会选择一种简单的方法:
\documentclass{article}
\usepackage[a4paper,margin=1in,landscape]{geometry}
\usepackage{makecell}
\usepackage{multirow}
\usepackage{booktabs}
\begin{document}
%\begin{landscape}
\begin{center}
\begin{table*}[!t] %
\centering
\caption{Results ...}
\begin{tabular}{|c|c|c|c|c|c|c|c|c|}
\hline
\textbf{Test} & \multicolumn{2}{c|}{Workflow} & Method
& Completion
& Gas Used for
& Gas Used for
& Actual/Complete
& Failed \\
& $|V|$ & $|E|$
&
& Time (min)
& \textit{submitJob} (gas)
& \textit{processPayment} (gas)
& Cost (\textit{Cent})
& \\
\hline
$T_1$ & 16 & 28 & ALGO & 27 & 1722983 & 1942770 & 0.827/0.827 & 0 \\ \hline
\end{tabular}
\end{table*}
\end{center}
%\end{landscape}
\end{document}
当然,“失败”不再位于中间,但“方法”也是如此