我正在尝试编译自动目录,但在使用时遇到了问题xtabular
。这是一个可编译的 MWE,没有任何标题。此示例确实可以编译:
\documentclass[10pt,twoside,table]{book}
\usepackage[paperheight=307mm,paperwidth=220mm,top=30mm,bottom=25mm,footskip=10mm,headsep=15mm,left=16mm,right=16mm,heightrounded]{geometry}
\usepackage{placeins}
%\usepackage[maxfloats=1000]{morefloats}
\usepackage[pages=all, placement=top]{background}
\usepackage{tikzpagenodes}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\usetikzlibrary{calc}
\usepackage[defaultfam,tabular,lining]{montserrat} %% Option 'defaultfam'
%% only if the base font of the document is to be sans serif
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\renewcommand*\oldstylenums[1]{{\fontfamily{Montserrat-TOsF}\selectfont #1}}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{calc}
\usepackage{lipsum}
\usepackage[pscoord]{eso-pic}
\definecolor{mycolor}{HTML}{1c6fa9}
\usepackage{fancyhdr}
\usepackage{changepage}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{colortbl}
\usepackage{xtab}
%\usepackage{supertabular}
\usepackage{datetime}
%\DeclareUnicodeCharacter{U+52}{è}
\usepackage{microtype}
\usepackage{pdfpages}
\begin{document}
\noindent
\renewcommand{\arraystretch}{0.8}
\setlength{\tabcolsep}{1pt}
\begin{multicols*}{2}
\begin{xtabular}{p{48px} p{50px} p{122px} p{37px}}
\tablefirsthead{\rowcolor{mycolor}
\multicolumn{3}{l}{\textcolor{white}{\textbf{MERCEDES-BENZ}}} & \textcolor{white}{p.}\\
\multicolumn{4}{l}{\scriptsize{\textbf{500 / 595 / 695 (312\_)}} \,\,\,\,\tiny{\textbf{8.2008 - }}}\\
\arrayrulecolor{mycolor}\hline}
\tablehead{\rowcolor{mycolor}
\multicolumn{3}{l}{\textcolor{white}{\textbf{MERCEDES-BENZ}}} & \textcolor{white}{p.}\\
\multicolumn{4}{l}{\scriptsize{\textbf{500 / 595 / 695 (312\_)}} \,\,\,\,\tiny{\textbf{8.2008 - }}}\\
\arrayrulecolor{mycolor}\hline}
\cellcolor{mycolor!20}\scriptsize{\textbf{23352}} & \cellcolor{mycolor!20}\tiny{735452143} & \cellcolor{mycolor!20}\ldots & \cellcolor{mycolor!20}\ldots\\
\FloatBarrier
\vspace{1mm}
\end{xtabular}
\end{multicols*}
\end{document}
但是,如果您编译上面的代码,就会发现我想要的表格双标题(分布在两列上,跨越多页)并没有出现在表格的第一列、第一页中。因此,我重复了以下两行标题块:
\rowcolor{mycolor}
\multicolumn{3}{l}{\textcolor{white}{\textbf{MERCEDES-BENZ}}} & \textcolor{white}{p.}\\
\multicolumn{4}{l}{\scriptsize{\textbf{500 / 595 / 695 (312\_)}} \,\,\,\,\tiny{\textbf{8.2008 - }}}\\
\arrayrulecolor{mycolor}\hline
获取:
\begin{multicols*}{2}
\begin{xtabular}{p{48px} p{50px} p{122px} p{37px}}
\tablefirsthead{\rowcolor{mycolor}
\multicolumn{3}{l}{\textcolor{white}{\textbf{MERCEDES-BENZ}}} & \textcolor{white}{p.}\\
\multicolumn{4}{l}{\scriptsize{\textbf{500 / 595 / 695 (312\_)}} \,\,\,\,\tiny{\textbf{8.2008 - }}}\\
\arrayrulecolor{mycolor}\hline}
\tablehead{\rowcolor{mycolor}
\multicolumn{3}{l}{\textcolor{white}{\textbf{MERCEDES-BENZ}}} & \textcolor{white}{p.}\\
\multicolumn{4}{l}{\scriptsize{\textbf{500 / 595 / 695 (312\_)}} \,\,\,\,\tiny{\textbf{8.2008 - }}}\\
\arrayrulecolor{mycolor}\hline}
\rowcolor{mycolor}
\multicolumn{3}{l}{\textcolor{white}{\textbf{MERCEDES-BENZ}}} & \textcolor{white}{p.}\\
\multicolumn{4}{l}{\scriptsize{\textbf{500 / 595 / 695 (312\_)}} \,\,\,\,\tiny{\textbf{8.2008 - }}}\\
\arrayrulecolor{mycolor}\hline
\cellcolor{mycolor!20}\scriptsize{\textbf{23352}} & \cellcolor{mycolor!20}\tiny{735452143} & \cellcolor{mycolor!20}\ldots & \cellcolor{mycolor!20}\ldots\\
\FloatBarrier
\vspace{1mm}
\end{xtabular}
\end{multicols*}
很容易验证,在这种情况下,由于 请求的特权,该指令\rowcolor{mycolor}
将生成 ,该特权希望成为任何单元格中的第一个命令。除此之外,无论如何, 都会出现 。有人可以解释最后一个错误的来源以及如何修复它吗?Misplaced \noalign
multicolumn
Misplaced \omit. ...\textcolor{white}{\textbf{MERCEDES-BENZ}}}
编辑
非常感谢你的回答,大卫,虽然这个答案没有解释两件事:
为什么如果我移动代码它却能完美编译?即
\documentclass[10pt,twoside,table]{book} \usepackage[paperheight=307mm,paperwidth=220mm,top=30mm,bottom=25mm,footskip=10mm,headsep=15mm,left=16mm,right=16mm,heightrounded]{geometry} \usepackage{placeins} %\usepackage[maxfloats=1000]{morefloats} \usepackage[pages=all, placement=top]{background} \usepackage{tikzpagenodes} \usepackage{tikz} \usetikzlibrary{backgrounds} \usetikzlibrary{calc} \usepackage[defaultfam,tabular,lining]{montserrat} %% Option 'defaultfam' %% only if the base font of the document is to be sans serif \usepackage[T1]{fontenc} \usepackage[utf8]{inputenc} \usepackage[italian]{babel} \renewcommand*\oldstylenums[1]{{\fontfamily{Montserrat-TOsF}\selectfont #1}} \usepackage{xcolor} \usepackage{graphicx} \usepackage{calc} \usepackage{lipsum} \usepackage[pscoord]{eso-pic} \definecolor{mycolor}{HTML}{1c6fa9} \usepackage{fancyhdr} \usepackage{changepage} \usepackage{multicol} \usepackage{multirow} \usepackage{colortbl} \usepackage{xtab} %\usepackage{supertabular} \usepackage{datetime} %\DeclareUnicodeCharacter{U+52}{è} \usepackage{microtype} \usepackage{pdfpages} \begin{document} \noindent \renewcommand{\arraystretch}{0.8} \setlength{\tabcolsep}{1pt} \begin{multicols*}{2} \begin{xtabular}{p{48px} p{50px} p{122px} p{37px}} \rowcolor{mycolor} \multicolumn{3}{l}{\textcolor{white}{\textbf{MERCEDES-BENZ}}} & \textcolor{white}{p.}\\ \multicolumn{4}{l}{\scriptsize{\textbf{500 / 595 / 695 (312\_)}} \,\,\,\,\tiny{\textbf{8.2008 - }}}\\ \arrayrulecolor{mycolor}\hline \tablefirsthead{\rowcolor{mycolor} \multicolumn{3}{l}{\textcolor{white}{\textbf{MERCEDES-BENZ}}} & \textcolor{white}{p.}\\ \multicolumn{4}{l}{\scriptsize{\textbf{500 / 595 / 695 (312\_)}} \,\,\,\,\tiny{\textbf{8.2008 - }}}\\ \arrayrulecolor{mycolor}\hline} \tablehead{\rowcolor{mycolor} \multicolumn{3}{l}{\textcolor{white}{\textbf{MERCEDES-BENZ}}} & \textcolor{white}{p.}\\ \multicolumn{4}{l}{\scriptsize{\textbf{500 / 595 / 695 (312\_)}} \,\,\,\,\tiny{\textbf{8.2008 - }}}\\ \arrayrulecolor{mycolor}\hline} \cellcolor{mycolor!20}\scriptsize{\textbf{23352}} & \cellcolor{mycolor!20}\tiny{735452143} & \cellcolor{mycolor!20}\ldots & \cellcolor{mycolor!20}\ldots\\ \cellcolor{mycolor!20}\scriptsize{\textbf{23352}} & \cellcolor{mycolor!20}\tiny{735452143} & \cellcolor{mycolor!20}\ldots & \cellcolor{mycolor!20}\ldots\\ \FloatBarrier \vspace{1mm} \end{xtabular} \end{multicols*} \end{document}
为什么当我通过堆叠多个这样的环境来重复 xtabular 时,标题会在第一个实例中被省略,但却被放置在接下来的实例中?
答案1
\tablehead
显然是这样的,所以\multicolumn
(或 noalign 结构,例如\rowcolor
)不能跟上。避免这个问题的一个稍微有点 hack 但却最简单的方法是给它一个空白行来处理,只需插入
\\[-\normalbaselineskip]
之前\rowcolor