\longtabu 环境中的 \multicolumn 问题

\longtabu 环境中的 \multicolumn 问题

我是 LaTeX 的新手,在longtabu表格方面遇到了问题。我已将其设置为交替行颜色,效果很好。但是,这会使除第一页之外的所有页眉都变成交替颜色。为了解决这个问题,我尝试\multicolumn在页眉中添加一行,如下面的 MWE 所示。我还在\multicolumn页脚中添加了一行,结果相同。

\documentclass[12pt]{article}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{tabu,xcolor,colortbl}
\usepackage{caption}
\usepackage{array}
\usepackage[colorlinks = true,
            linkcolor = blue,
            urlcolor  = blue,
            citecolor = blue,
            anchorcolor = blue]{hyperref}            
\usepackage{longtable}


\begin{document}

\taburowcolors[2]{white .. blue!20}

\tabulinesep=6pt
\arrayrulewidth=1pt 

\begin{longtabu}[h]{| m{1.75in} | m{1.5in} | m{2.75in} |}


\caption{This is the first page header} \label{Table:example}\\
 \rowcolor{blue}\color{white}Column 1  & \color{white}Column 2 & \color{white}Column 3\\
\endfirsthead

\rowcolor{white}\multicolumn{3}{c}{Table~\ref{Table:example}: Continued from previous page}\\
%\caption{Continued from previous page}\\
 \rowcolor{blue}\color{white}Column 1  & \color{white}Column 2 & \color{white}Column 3\\ 
\endhead

\hline
%\rowcolor{white} \multicolumn{3}{l}{Continued on next page}\\ 

\endfoot

\hline
\endlastfoot


This is Column 1 & This column describes Column 1 and is generally a little longer &  This is a longer description that will take up a few lines of text in the table. It is really just a bunch of text. This really means nothing in this minimum working example other than to take up space in the table.\\

This is Column 1 & This column describes Column 1 and is generally a little longer &  This is a longer description that will take up a few lines of text in the table. It is really just a bunch of text. This really means nothing in this minimum working example other than to take up space in the table.\\

This is Column 1 & This column describes Column 1 and is generally a little longer &  This is a longer description that will take up a few lines of text in the table. It is really just a bunch of text. This really means nothing in this minimum working example other than to take up space in the table.\\

This is Column 1 & This column describes Column 1 and is generally a little longer &  This is a longer description that will take up a few lines of text in the table. It is really just a bunch of text. This really means nothing in this minimum working example other than to take up space in the table.\\

This is Column 1 & This column describes Column 1 and is generally a little longer &  This is a longer description that will take up a few lines of text in the table. It is really just a bunch of text. This really means nothing in this minimum working example other than to take up space in the table.\\

This is Column 1 & This column describes Column 1 and is generally a little longer &  This is a longer description that will take up a few lines of text in the table. It is really just a bunch of text. This really means nothing in this minimum working example other than to take up space in the table.\\

This is Column 1 & This column describes Column 1 and is generally a little longer &  This is a longer description that will take up a few lines of text in the table. It is really just a bunch of text. This really means nothing in this minimum working example other than to take up space in the table.\\

This is Column 1 & This column describes Column 1 and is generally a little longer &  This is a longer description that will take up a few lines of text in the table. It is really just a bunch of text. This really means nothing in this minimum working example other than to take up space in the table.\\

This is Column 1 & This column describes Column 1 and is generally a little longer &  This is a longer description that will take up a few lines of text in the table. It is really just a bunch of text. This really means nothing in this minimum working example other than to take up space in the table.\\

This is Column 1 & This column describes Column 1 and is generally a little longer &  This is a longer description that will take up a few lines of text in the table. It is really just a bunch of text. This really means nothing in this minimum working example other than to take up space in the table.\\

This is Column 1 & This column describes Column 1 and is generally a little longer &  This is a longer description that will take up a few lines of text in the table. It is really just a bunch of text. This really means nothing in this minimum working example other than to take up space in the table.\\


\end{longtabu}

\end{document}

这有效,但会引发一些 Misplaced\omit \end{longtabu}

错误以及一堆过满和欠满,\hbox如下所示。

line 66: Misplaced \omit \end{longtabu}
line 66: Misplaced \omit \end{longtabu}
line 66: Overfull \hbox (43.61536pt too wide) in alignment
line 66: Overfull \hbox (43.61536pt too wide) in alignment
line 66: Overfull \hbox (43.61536pt too wide) in alignment
line 66: Overfull \hbox (43.61536pt too wide) in alignment
line 66: Underfull \hbox (badness 10000) in paragraph
line 66: Underfull \hbox (badness 10000) in paragraph
line 66: Underfull \hbox (badness 2837) in paragraph
line 66: Underfull \hbox (badness 10000) in paragraph
line 66: Underfull \hbox (badness 10000) in paragraph
line 66: Underfull \hbox (badness 2837) in paragraph
line 66: Underfull \hbox (badness 10000) in paragraph
line 66: Underfull \hbox (badness 10000) in paragraph
line 66: Underfull \hbox (badness 2837) in paragraph
line 66: Underfull \hbox (badness 10000) in paragraph
line 66: Underfull \hbox (badness 10000) in paragraph
line 66: Underfull \hbox (badness 2837) in paragraph
line 66: Underfull \hbox (badness 10000) in paragraph
line 66: Underfull \hbox (badness 10000) in paragraph
line 66: Underfull \hbox (badness 2837) in paragraph
line 66: Underfull \hbox (badness 10000) in paragraph
line 66: Underfull \hbox (badness 10000) in paragraph
line 66: Underfull \hbox (badness 2837) in paragraph
line 66: Underfull \hbox (badness 10000) in paragraph
line 66: Underfull \hbox (badness 10000) in paragraph
line 66: Underfull \hbox (badness 2837) in paragraph
line 66: Underfull \hbox (badness 10000) in paragraph
line 66: Underfull \hbox (badness 10000) in paragraph
line 66: Underfull \hbox (badness 2837) in paragraph
line 66: Underfull \hbox (badness 10000) in paragraph
line 66: Underfull \hbox (badness 10000) in paragraph
line 66: Underfull \hbox (badness 2837) in paragraph
line 66: Underfull \hbox (badness 10000) in paragraph
line 66: Underfull \hbox (badness 10000) in paragraph
line 66: Underfull \hbox (badness 2837) in paragraph
line 66: Underfull \hbox (badness 10000) in paragraph
line 66: Underfull \hbox (badness 10000) in paragraph
line 66: Underfull \hbox (badness 2837) in paragraph
line 66: Overfull \hbox (43.61536pt too wide) in alignment

我能做些什么来消除这些错误?

谢谢

答案1

使用\cellcolor,而不是\rowcolor

\begin{longtabu}{| >{\raggedright}m{1.75in} | >{\raggedright}m{1.5in} | >{\raggedright\arraybackslash}m{2.75i$


\caption{This is the first page header} \label{Table:example}\\
 \rowcolor{blue}\color{white}Column 1  & \color{white}Column 2 & \color{white}Column 3\\
\endfirsthead

\multicolumn{3}{c}{\cellcolor{white}Table~\ref{Table:example}: Continued from previous page}\\[\bigskipamount]
 \rowcolor{blue}\color{white}Column 1  & \color{white}Column 2 & \color{white}Column 3\\
\endhead

我设置了一个小边距只是为了避免表格超出宽度。\raggedright单元格不会抛出数十个Underfull \hbox警告。

在此处输入图片描述

相关内容