![longtabu 的标题内有多列并抛出 \omit 错误](https://linux22.com/image/269831/longtabu%20%E7%9A%84%E6%A0%87%E9%A2%98%E5%86%85%E6%9C%89%E5%A4%9A%E5%88%97%E5%B9%B6%E6%8A%9B%E5%87%BA%20%5Comit%20%E9%94%99%E8%AF%AF.png)
我在使用时遇到了错误longtabu
。我有一个例子,说明它在没有标题的情况下工作正常,但在标题中\multicolumn
有时却不工作。\multicolumn
\documentclass[10pt,letterpaper]{article}
\usepackage{comment}
\usepackage[top=2cm,bottom=4cm,left=2cm,right=2cm]{geometry}
\usepackage{colortbl}
\usepackage{tikz}
\usepackage{tabu}
\usepackage{longtable}
\usepackage{siunitx}
\begin{document}
\begin{longtabu} to \linewidth{|c|c|X|c|}
\hline
\rowfont\bfseries
\rowcolor{lightgray}
\multicolumn{2}{|c|}{From / To} & Description & Cost \\
\hline
\endfirsthead
\caption[]{(continued)}\\
\hline
\rowfont\bfseries
\rowcolor{lightgray}
From & To & Description & Cost \\
\hline
\endhead
\rowfont\bfseries
\multicolumn{4}{|l|}{\cellcolor{cyan}DAY 1 -- 2012-10-15} \\
\hline
1:00 & 2:00 & Action & \\
\hline
1:00 & 2:00 & Action & \\
\hline
\end{longtabu}
\begin{longtabu} to \linewidth{|c|c|X|c|}
\hline
\rowfont\bfseries
\rowcolor{lightgray}
From & To & Description & Cost \\
\hline
\endfirsthead
\caption[]{(continued)}\\
\hline
\rowfont\bfseries
\rowcolor{lightgray}
From & To & Description & Cost \\
\hline
\endhead
\rowfont\bfseries
\multicolumn{4}{|l|}{\cellcolor{cyan}DAY 1 -- 2012-10-15} \\
\hline
1:00 & 2:00 & Action & \\
\hline
1:00 & 2:00 & Action & \\
\hline
\end{longtabu}
\end{document}
\multicolumn
表 1 会抛出错误,表 2 则正常工作。两者之间的唯一区别是在表 1 的标题中使用了。我\multicolumn
分别在 firsthead 和 head 中以及在两者中测试了使用,并抛出了相同的错误。
! Misplaced \omit.
\multispan ->\omit
\@multispan
l.33 \end{longtabu}
答案1
也许它应该可以工作,但是因为它不工作,你可以使用
\hline
\rowfont\bfseries
\multicolumn{2}{|c|}{\cellcolor{lightgray}From / To} & \cellcolor{lightgray}Description &\cellcolor{lightgray} Cost \\
\hline
\endfirsthead