![考虑表头和表头偏移来限制长表的大小](https://linux22.com/image/372626/%E8%80%83%E8%99%91%E8%A1%A8%E5%A4%B4%E5%92%8C%E8%A1%A8%E5%A4%B4%E5%81%8F%E7%A7%BB%E6%9D%A5%E9%99%90%E5%88%B6%E9%95%BF%E8%A1%A8%E7%9A%84%E5%A4%A7%E5%B0%8F.png)
longtable
我正在尝试在模式中输入lscape
,但我想做的是限制其大小,从页面底部一直到任何文本应该在的顶部,即考虑页眉 + 页眉偏移量。如果我输入以下代码:
\documentclass[12pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{lscape}
\usepackage{longtable}
\usepackage{fancyhdr}
\pagestyle{fancy}
\begin{document}
\section{Limiting a table to header + offset}
Here I am trying to limit the size of table, which should be from the bottom of the page (as it is the case now), to where any text would be i.e. all the way to the header + headeroffset.
\begin{landscape}
\begin{longtable}[c]{
p{0.125\hsize}
p{0.125\hsize}
p{0.125\hsize}
p{0.125\hsize}
p{0.125\hsize}
p{0.125\hsize}
p{0.125\hsize}
p{0.125\hsize}}
\caption{My caption}
\label{my-label}\\
\hline
old IDs & Score & Mass & Old Gene Product & signalP & exosomes & new IDs & New Gene Product \\ \hline
\endfirsthead
%
\multicolumn{8}{c}%
{{\bfseries Table \thetable\ continued from previous page}} \\
\hline
old IDs & Score & Mass & Old Gene Product & signalP & exosomes & new IDs & New Gene Product \\ \hline
\endhead
%
\hline
\endfoot
%
\endlastfoot
%
LdBPKxxxxxx.1 & 5140 & 71509 & heat-shock protein hsp70, putative & no & yes & LdBPKxxxxxx & heat-shock protein hsp70, putative \\
LdBPKxxxxx.1 & 3987 & 94942 & elongation factor 2 & no & yes & LdBPK\_360006900 & elongation factor 2 \\
LdBPKxx.1 & 2463 & 77764 & thimet oligopeptidase, putative & no & yes & LdBPKxxxxx & thimet oligopeptidase, putative \\
LdBPKxxxxx.1 & 2039 & 87562 & Transitional endoplasmic reticulum ATPase, putative & no & yes & LdBPKxxxxx & Transitional endoplasmic reticulum ATPase, putative \\
LdBPKxxxxx.1 & 1917 & 46634 & enolase & no & yes & LdBPKxxxxx & enolase \\ \hline
\end{longtable}
\end{landscape}
\end{document}
我们可以看到我的表格跨越了标题 + 标题偏移量。如何限制表格的高度,使其不跨越标题 + 标题偏移量?
换句话说,我试图将这个距离(页面底部一直到限制标题 + 标题偏移)指定为 100%,并为表格的每一列分配一个百分比值(占 100%)作为其宽度。
我猜这与我传递的用于指定列宽的参数有关,因为我猜它\hsize
没有考虑标题和标题偏移量。
答案1
你的桌子太宽了(见大卫·卡莱尔回答)。
编辑:
尝试使用该包修改您的表格,ltablex
如下所示:
\documentclass[12pt,a4paper]{article}
\usepackage[latin1]{inputenc}
%\usepackage{amsmath}
%\usepackage{amsfonts}
%\usepackage{amssymb}
%\usepackage{graphicx}
\usepackage{pdflscape}
\usepackage{array, ltablex} % <--- changed
\usepackage{fancyhdr}
\pagestyle{fancy}
\begin{document}
\section{Limiting a table to header + offset}
Here I am trying to limit the size of table, which should be from the bottom of the page (as it is the case now), to where any text would be i.e. all the way to the header + headeroffset.
\begin{landscape}
\small
\begin{tabularx}{\linewidth}{@{}
l
c
c
>{\raggedright\arraybackslash}X% <--- changed
c
c
l
>{\raggedright\arraybackslash}X
@{}}
\caption{My caption}
\label{my-label}\\
\hline
old IDs & Score & Mass & Old Gene Product & signalP & exosomes & new IDs & New Gene Product \\ \hline
\endfirsthead
%
\multicolumn{8}{c}%
{{\bfseries Table \thetable\ continued from previous page}} \\
\hline
old IDs & Score & Mass & Old Gene Product & signalP & exosomes & new IDs & New Gene Product \\ \hline
\endhead
%
\hline
\endfoot
%
\endlastfoot
%
LdBPKxxxxxx.1 & 5140 & 71509 & heat-shock protein hsp70, putative & no & yes & LdBPKxxxxxx & heat-shock protein hsp70, putative \\
LdBPKxxxxx.1 & 3987 & 94942 & elongation factor 2 & no & yes & LdBPK\_360006900 & elongation factor 2 \\
LdBPKxx.1 & 2463 & 77764 & thimet oligopeptidase, putative & no & yes & LdBPKxxxxx & thimet oligopeptidase, putative \\
LdBPKxxxxx.1 & 2039 & 87562 & Transitional endoplasmic reticulum ATPase, putative & no & yes & LdBPKxxxxx & Transitional endoplasmic reticulum ATPase, putative \\
LdBPKxxxxx.1 & 1917 & 46634 & enolase & no & yes & LdBPKxxxxx & enolase \\ \hline
\end{tabularx}
\end{landscape}
该包集成了和包ltablex
的功能。您可以使用它来使用列类型,它是根据可用的表宽度计算的。longtable
tabularx
X
答案2
您强行将其设置得太宽,因此只需将其缩小一点即可。所有列的宽度都是固定的,因此表格的宽度是列宽度的 8 倍,每列的宽度为\hsize
/8+2,\tabcolsep
因此表格的宽度为 16 \tabcolsep
,因此默认情况下 96pt 太宽了。