我正在尝试用 LaTeX 编写列标题,以便每个标题跨越两列;但是,以下代码不起作用:
\usepackage{booktabs}
\begin{tabular}{cccc}
\toprule
\multicolumn{2}{c}{Assets} & \multicolumn{2}{c}{Liabilities and Equities} \\
\cmidrule(r){1-2} \cmidrule(r){3-4}
Cash & \$13,152 & Short position (200 shares owed) & \$13,152 \\
\bottomrule
\end{tabular}
Assets
应该跨越前两列,也Liabilities and Equities
应该跨越第二对。当我编译它时,我收到此错误:
Misplaced \omit.
\multispan ->\omit
\@multispan
l.221 ...lticolumn{2}{c}{Liabilities and Equities}
谢谢!
编辑:现在正确了!请查看我的评论。由于我是新手,我暂时无法添加答案,但也许其他人可以,我会投票赞成。
答案1
&
很高兴您已经注意到了两个语句之间的缺失。还有一件事:您可能希望将第二个语句\multicolumn
的修剪选项从 更改为,以便在两行之间获得更多的水平分离。祝您 TeXing 愉快!\cmidrule
(r)
(l)
答案2
你似乎遗漏了&
:
\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{cccc}
\toprule
\multicolumn{2}{c}{Assets} &\multicolumn{2}{c}{Liabilities and Equities} \\
\cmidrule(r){1-2} \cmidrule(r){3-4}
Cash & \$13,152 & Short position (200 shares owed) & \$13,152 \\
\bottomrule
\end{tabular}
\end{document}