我有大量的表格(几十个),其中包含氨基酸或 DNA 核苷酸序列,并且是由半自动化生物信息学工作流程生成的。
这些表格相当长,通常长达两页甚至三页,因此我需要使用支持多页排版功能的表格制作环境。我决定使用xtab
包,基于我在第 3.4.2 节中找到的建议这个文件在tug.org上:
xtab 包的功能与 supertabular 非常相似,但它修正了一些缺陷,因此值得推荐。
它提供的一项不错的功能xtab
是可以打印表格标题,该标题将出现在第一页之后的每个后续页面的顶部。但是,当xtab
在中间线附近创建分页符时,它似乎总是倾向于立即放置分页符前中间规则,这样中间规则就会出现在下一页的顶部,而不是前一页的底部。虽然当多页表头功能被禁用时,这可能看起来不错,但当多页表头运行时,它看起来是错误的。
下面,我包含了一个 MWE,以及使用它进行编译时生成的输出的屏幕截图xelatex
:
% Basic document setup
\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\geometry{letterpaper}
\usepackage{fontspec}
\setmainfont{Tinos}
% Table-specific setup
\usepackage{xtab} % Needed for multi-page tables
\usepackage{multirow} % Needed because some cells span 2 rows
\usepackage{booktabs} % Improves appearance of horizontal lines and rules
\newcommand{\otoprule }{\midrule[\heavyrulewidth]}
\usepackage{seqsplit} % Needed for line breaking amino acid sequences
\usepackage{siunitx} % Needed for aligning numbers in columns
\sisetup{
table-format = 2.2
}
\begin{document}
\begin{center}
% Print this header at the top of the first page. Enclose 3rd column in
% brackets as a workaround to a weird bug that seems to arise from an
% interaction between xtab and siunitx packages.
\tablefirsthead{\toprule
Name & Type & {ID Number} & Amino Acid Sequences \\
\otoprule}
% Print this header at the top of all subsequent pages -- I made it identical
% to above, but in principle it could be different
\tablehead{\toprule
Name & Type & {ID Number} & Amino Acid Sequences \\
\otoprule}
% Begin actual table body
\begin{xtabular}{lcS[table-number-alignment = right]p{0.6\textwidth}}
\multirow[t]{2}{*}{ABCD1001} & A & 1 & \seqsplit{CVPCYFWIIQMADNYCCYFMSRMCRPVFMTGHKWWANNQCVERSVTHKDFGRANAAFAKAYTGRNYHCNYKRYWYNNATQYPHMAEWHT} \\
\cmidrule(l){2-4}
& B & 2 & \seqsplit{AAWLYALGCQTDVYDISKYIQCGLEYRIGPCQRPGGWGYYFFHFFDVWTIDSAPDISVIKDRKKCMEQTADTISHVGLGTESTPKQIIAALLGDYGFLGCYNEL} \\
\midrule
\multirow[t]{2}{*}{ABCD1002} & A & 3 & \seqsplit{VMKCDPLWSDLFWTFNRMVKKKCDCARILFEVRVWISCQLMVSYLNWSIILEIRLIGEFSHGQQIWRLFNTKTDRWMVDEDGDNHFQRKVICFFNVRQDMPPNLFFTVWNDWMHTQTDH} \\
\cmidrule(l){2-4}
& B & 4 & \seqsplit{FRTWPHLAQESTRSITTLPRRISFMFCYDQYNEMRPACVICSDMVAYYILAPGKGAFTCEWVGRAVMNHHEHDMQMGEAIHRQEIYVHKDWDAI} \\
\midrule
\multirow[t]{2}{*}{ABCD1003} & A & 5 & \seqsplit{SIDYDEESNMPHDPQEEWWNTLPHQKYPLGCGQEDPWDYKNNIFRAYAWIYEWNHVKHDKTAIHTHVVKQAHCPNRHFFGFLCNLSQELMNSF} \\
\cmidrule(l){2-4}
& B & 6 & \seqsplit{EEDRYNFYVNWIADRFLVCKPEFWDAFLYKKLWCFATNSKAFGETDCYKDAWYYFIHPEEKMSDQATWEAGIMNWLQEQTMVQQQTDCISA} \\
\midrule
\multirow[t]{2}{*}{ABCD1004} & A & 7 & \seqsplit{AYRIGEDGRFRQGRDKINKYDRATHFLQYHGRTVWRWHQYEKVYTFIMAYVPGFQYCPDGVPYVNSRAKYHKGVWCCDIQWVQEACEWSGFCLNARTCACCRHRGSDVVQASK} \\
\cmidrule(l){2-4}
& B & 8 & \seqsplit{NGLGSNQQVVSVGMNMLCFFKPFFGHNAGGYDVQAVHVWSDLDIHTDGDWHNNSCMTSIVDAPQTPHLMWNAPKWNIAWPVPPVNGYTIFKPHSKTIMAKNVEGEQECVHFKNQA} \\
\midrule
\multirow[t]{2}{*}{ABCD1005} & A & 9 & \seqsplit{FNFHFPQDPYHGEGTGPDDVMWKEKSLPTPIWVLWKIEYNVVAHCLRGSPNYNNADRGDCCHAFQNHKEIWQDAITIFENGWCSCIDKCAQSVDIPIDHQEQCNKMQHCDAAME} \\
\cmidrule(l){2-4}
& B & 10 & \seqsplit{CCIYPFWIACCHCFELTAEQFSFCYGVQHVYHPEYSDKLCNNQFFSSILNRHYIPYAAGGWEQAMVVCKLFQPVMVKKWNTDFSHADCR} \\
\midrule
\multirow[t]{2}{*}{ABCD1006} & A & 11 & \seqsplit{KPIPQESQYAWLVNLVTMCCAGRAWSLAERMHFYCQMSSIGAHPGHVRGGRWEAEIIQNHGENLHRTDRVAFKMTYPTKFCRYVITQFMMQQWLQHNPYQGMIMHIIVGVRSNTILE} \\
% Uncommenting the line below results in a xelatex compilation error
% \nopagebreak
\cmidrule(l){2-4}
& B & 12 & \seqsplit{IWCTCISSPDKWWEDPKLYSYNWHKVAIMLGYFASVMFCIYQSCYIIAMLRMNPFRCWNSWVDVCIIQGYGCSKKQDVKDFEHLQYGNFIETVR} \\
\midrule
\multirow[t]{2}{*}{ABCD1007} & A & 13 & \seqsplit{NDAEWKGALINLVGMESQWKNRHGDYYGYAGRVYIPCNAQFVCWCNDLHEMVYNTMGPPCIPHMGISERSWFSCQNDVHRYGPAHVDRSVCVRFMEHVDHSVMKLVPHELTSSGI} \\
\cmidrule(l){2-4}
& B & 14 & \seqsplit{YHQQACAYPSYRFTSWNCEDAKYEKKIQWVAKTQFFGWPTPFMSDNPGEQDSKTLMFIRMPYPGEYFNQNRQNSGQLQRDQYGRWNCQKDYYMQNCFCT} \\
\bottomrule
\end{xtabular}
\end{center}
\end{document}
理想情况下,我想在所有中线规则之前系统地抑制分页符(从而强制分页符在下一个中线规则之后立即发生),但是,当我实际在命令中尝试这样做时xtab
,\nopagebreak
却出现了错误消息。
我的问题:xtab
除此之外,我还可以使用哪些其他惩罚技术\nopagebreak
来强制换行始终发生在中线规则之后而不是之前?
另外,在回答之前,请注意一个高度具体的逆解,其中我力量让换行符出现在非常特定的位置,这是不可取的。正如我在开头所说的,我有几十个表格要处理,我仍然希望xelatex
大部分思考工作都由别人替我完成——我不想对几十个表格进行繁琐的手动更正;相反,我只想在相当高的水平上对分页符相关的评分系统产生一点影响。例如,我想到一个很好的解决方案可能是简单地重新定义和命令,\midrule
以便\cmidrule
这些booktabs
命令本身以某种方式表明xelatex
它们更愿意在打印后而不是打印前进行分页。但是,我不知道人们实际上应该如何去做这样的事情。
答案1
根据用户 Tomáš Kruliš 的评论,我尝试用longtable
包代替xtab
,这确实似乎解决了这个问题。修订后的 MWE 及其结果输出发布如下:
% Basic document setup
\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\geometry{letterpaper}
\usepackage{fontspec}
\setmainfont{Tinos}
% Table-specific setup
\usepackage{longtable} % Needed for multi-page tables
\usepackage{multirow} % Needed because some cells span 2 rows
\usepackage{booktabs} % Improves appearance of horizontal lines and rules
\newcommand{\otoprule }{\midrule[\heavyrulewidth]}
\usepackage{seqsplit} % Needed for line breaking amino acid sequences
\usepackage{siunitx} % Needed for aligning numbers in columns
\sisetup{
table-format = 2.2
}
\begin{document}
\begin{center}
% Begin actual table body
\begin{longtable}{lcS[table-number-alignment = right]p{0.6\textwidth}}
\toprule Name & Type & {ID Number} & Amino Acid Sequences \\ \otoprule \endhead
\multirow[t]{2}{*}{ABCD1001} & A & 1 & \seqsplit{CVPCYFWIIQMADNYCCYFMSRMCRPVFMTGHKWWANNQCVERSVTHKDFGRANAAFAKAYTGRNYHCNYKRYWYNNATQYPHMAEWHT} \\
\cmidrule(l){2-4}
& B & 2 & \seqsplit{AAWLYALGCQTDVYDISKYIQCGLEYRIGPCQRPGGWGYYFFHFFDVWTIDSAPDISVIKDRKKCMEQTADTISHVGLGTESTPKQIIAALLGDYGFLGCYNEL} \\
\midrule
\multirow[t]{2}{*}{ABCD1002} & A & 3 & \seqsplit{VMKCDPLWSDLFWTFNRMVKKKCDCARILFEVRVWISCQLMVSYLNWSIILEIRLIGEFSHGQQIWRLFNTKTDRWMVDEDGDNHFQRKVICFFNVRQDMPPNLFFTVWNDWMHTQTDH} \\
\cmidrule(l){2-4}
& B & 4 & \seqsplit{FRTWPHLAQESTRSITTLPRRISFMFCYDQYNEMRPACVICSDMVAYYILAPGKGAFTCEWVGRAVMNHHEHDMQMGEAIHRQEIYVHKDWDAI} \\
\midrule
\multirow[t]{2}{*}{ABCD1003} & A & 5 & \seqsplit{SIDYDEESNMPHDPQEEWWNTLPHQKYPLGCGQEDPWDYKNNIFRAYAWIYEWNHVKHDKTAIHTHVVKQAHCPNRHFFGFLCNLSQELMNSF} \\
\cmidrule(l){2-4}
& B & 6 & \seqsplit{EEDRYNFYVNWIADRFLVCKPEFWDAFLYKKLWCFATNSKAFGETDCYKDAWYYFIHPEEKMSDQATWEAGIMNWLQEQTMVQQQTDCISA} \\
\midrule
\multirow[t]{2}{*}{ABCD1004} & A & 7 & \seqsplit{AYRIGEDGRFRQGRDKINKYDRATHFLQYHGRTVWRWHQYEKVYTFIMAYVPGFQYCPDGVPYVNSRAKYHKGVWCCDIQWVQEACEWSGFCLNARTCACCRHRGSDVVQASK} \\
\cmidrule(l){2-4}
& B & 8 & \seqsplit{NGLGSNQQVVSVGMNMLCFFKPFFGHNAGGYDVQAVHVWSDLDIHTDGDWHNNSCMTSIVDAPQTPHLMWNAPKWNIAWPVPPVNGYTIFKPHSKTIMAKNVEGEQECVHFKNQA} \\
\midrule
\multirow[t]{2}{*}{ABCD1005} & A & 9 & \seqsplit{FNFHFPQDPYHGEGTGPDDVMWKEKSLPTPIWVLWKIEYNVVAHCLRGSPNYNNADRGDCCHAFQNHKEIWQDAITIFENGWCSCIDKCAQSVDIPIDHQEQCNKMQHCDAAME} \\
\cmidrule(l){2-4}
& B & 10 & \seqsplit{CCIYPFWIACCHCFELTAEQFSFCYGVQHVYHPEYSDKLCNNQFFSSILNRHYIPYAAGGWEQAMVVCKLFQPVMVKKWNTDFSHADCR} \\
\midrule
\multirow[t]{2}{*}{ABCD1006} & A & 11 & \seqsplit{KPIPQESQYAWLVNLVTMCCAGRAWSLAERMHFYCQMSSIGAHPGHVRGGRWEAEIIQNHGENLHRTDRVAFKMTYPTKFCRYVITQFMMQQWLQHNPYQGMIMHIIVGVRSNTILE} \\
% Uncommenting the line below results in a xelatex compilation error
% \nopagebreak
\cmidrule(l){2-4}
& B & 12 & \seqsplit{IWCTCISSPDKWWEDPKLYSYNWHKVAIMLGYFASVMFCIYQSCYIIAMLRMNPFRCWNSWVDVCIIQGYGCSKKQDVKDFEHLQYGNFIETVR} \\
\midrule
\multirow[t]{2}{*}{ABCD1007} & A & 13 & \seqsplit{NDAEWKGALINLVGMESQWKNRHGDYYGYAGRVYIPCNAQFVCWCNDLHEMVYNTMGPPCIPHMGISERSWFSCQNDVHRYGPAHVDRSVCVRFMEHVDHSVMKLVPHELTSSGI} \\
\cmidrule(l){2-4}
& B & 14 & \seqsplit{YHQQACAYPSYRFTSWNCEDAKYEKKIQWVAKTQFFGWPTPFMSDNPGEQDSKTLMFIRMPYPGEYFNQNRQNSGQLQRDQYGRWNCQKDYYMQNCFCT} \\
\bottomrule
\end{longtable}
\end{center}
\end{document}
尽管如此,尽管如此,我仍然非常有兴趣看到(并很乐意投票,并可能授予“首选答案”状态)能够通过使用xtab
并修改其分页符评分系统来解决这个问题的回应。