我正在尝试将多页长表移到文档中设置的边距左侧,但由于我对 LaTeX 完全陌生,因此遇到了一些困难。我在 Excel 中有一个大表,我已使用网站将其转换为 LaTeX 中的长表环境表格生成器,将其复制到我的 tex 文件中。
以下是 MWE:
%% Define document class with options
\documentclass[12pt,twoside,openright]{report}
\usepackage{geometry} % Easy modification of the page layout.
\geometry{a4paper,inner=28mm,outer=25mm,top=25mm,bottom=25mm} % Required layout
\usepackage{booktabs, longtable, pdflscape, fancyhdr}
\usepackage[skip=1ex]{caption}
% Getting landscape page and page number/footer on bottom of page (instead of to the left)
\fancypagestyle{mylandscape}{
\fancyhf{} %Clears the header/footer
\fancyfoot{% Footer
\makebox[\textwidth][r]{% Right
\rlap{\hspace{1.5cm}% Push out of margin by \footskip
\smash{% Remove vertical height
\raisebox{13.6cm}{% Raise vertically
\rotatebox{90}{\thepage}}}}}}% Rotate counter-clockwise
\renewcommand{\headrulewidth}{0pt}% No header rule
\renewcommand{\footrulewidth}{0pt}% No footer rule
}
% For table headers with line breaks
\usepackage{fourier}
\usepackage{array}
\usepackage{makecell}
\renewcommand\theadalign{bc}
\renewcommand\theadfont{\bfseries}
\renewcommand\theadgape{\Gape[4pt]}
\renewcommand\cellgape{\Gape[4pt]}
\begin{document}
\begin{landscape}
\pagestyle{mylandscape}
\begin{center}
\scriptsize
\begin{longtable}[c]{@{}cccccccccccccccc@{}}
\caption{\textbf{Caption heading.} Some caption.}
\label{tab:table1}\\
\toprule
\multicolumn{1}{c}{\thead{Method}} &
\multicolumn{1}{c}{\thead{Sample ID}} &
\multicolumn{1}{c}{\thead{Statistics}} &
\multicolumn{1}{c}{\thead{A long\\ header}} &
\multicolumn{1}{c}{\thead{Another\\ statistic}}&
\multicolumn{1}{c}{\thead{More\\ statistics}} &
\multicolumn{1}{c}{\thead{Number of\\ something}} &
\multicolumn{1}{c}{\thead{Number of\\ something else}} &
\multicolumn{1}{c}{\thead{Number of\\ something similar}} &
\multicolumn{1}{c}{\thead{Number of\\ unique\\ something}} &
\multicolumn{1}{c}{\thead{Number of\\ specific\\ stuff here}} &
\multicolumn{1}{c}{\thead{Interesting\\ stuff about\\ something}} &
\multicolumn{1}{c}{\thead{LaTeX \\ is hard}} &
\multicolumn{1}{c}{\thead{ButI\\ cool}} &
\multicolumn{1}{c}{\thead{Sampling\\ day}} \\* \midrule
\endfirsthead
%
\multicolumn{16}{c}%
{{\bfseries Table \thetable\ continued from previous page}} \\
\toprule
\multicolumn{1}{c}{\thead{Method}} &
\multicolumn{1}{c}{\thead{Sample ID}} &
\multicolumn{1}{c}{\thead{Statistics}} &
\multicolumn{1}{c}{\thead{A long\\ header}} &
\multicolumn{1}{c}{\thead{Another\\ statistic}} &
\multicolumn{1}{c}{\thead{More\\ statistics}} &
\multicolumn{1}{c}{\thead{Number of\\ something}} &
\multicolumn{1}{c}{\thead{Number of\\ something else}} &
\multicolumn{1}{c}{\thead{Number of\\ something similar}} &
\multicolumn{1}{c}{\thead{Number of\\ unique\\ something}} &
\multicolumn{1}{c}{\thead{Number of\\ specific\\ stuff here}} &
\multicolumn{1}{c}{\thead{Interesting\\ stuff about\\ something}} &
\multicolumn{1}{c}{\thead{LaTeX \\ is hard}} &
\multicolumn{1}{c}{\thead{ButI\\ cool}} &
\multicolumn{1}{c}{\thead{Sampling\\ day}} \\* \midrule
\endhead
%
\bottomrule
\endfoot
%
\endlastfoot
%
METHOD 1 & 1-D0-VO-L-3 & 60 & 0,5 & 1,57 & 1116,23 & 911 & 467 & 421 & 291 & 98 & 52 & Freshwater & VO & 0 \\
METHOD 1 & 1-D0-VO-L-T1-1 & 49 & 0,4 & 1,37 & 766,17 & 891 & 432 & 394 & 275 & 94 & 53 & Saltwater & VO & 0 \\
METHOD 1 & 10-D0-MA-L-T1-2 & 58 & 0,48 & 1,51 & 757,45 & 868 & 451 & 405 & 278 & 98 & 58 & Saltwater & MA & 0 \\
[…]
METHOD 4 & 39-D6-MA-VO-L-T2-1 & 17 & 0,14 & 1,01 & 1553,21 & 659 & 257 & 269 & 194 & 50 & 26 & Saltwater & MA-VO & 6 \\
METHOD 4 & 40-D6-MA-VO-L-T2-2 & 17 & 0,14 & 1,01 & 2181,26 & 595 & 231 & 242 & 172 & 44 & 27 & Saltwater & MA-VO & 6 \\
METHOD 4 & 9-D6-VO-L-1 & 108 & 0,89 & 1,61 & 781,27 & 1080 & 677 & 503 & 338 & 167 & 82 & Freshwater & VO & 6 \\* \bottomrule
\end{longtable}
\end{center}
\end{landscape}
\end{document}
从前两页可以看出,我刚刚将表格放在了页面框架内,但我非常想将其向左移动一点,以便在其两边留出一些空白。经过几个小时的谷歌搜索解决方案后,我在这个讨论论坛上遇到了几个类似的问题,例如:
- 使用 \setlengthLTleft{-2cm}
- \begin{调整宽度}{-2cm}{}{…}\end{调整宽度}
- \begingroup 与 \setlength
- \setlength\LTcapwidth{\textwidth}
- [\makebox\textwidth][c]{\includegraphics[width=1.2\textwidth]{image}} (虽然我认为这适用于图形而不是表格)
我尝试实现所有这些(以及一些我无法找到的其他功能),但不幸的是没有任何成功。无论如何,表格似乎都不想改变位置。因此,我希望有人能够帮助我解决我的具体问题。任何帮助都非常感谢!
答案1
移除center
(它没有将 置于中心longtable
)并移除[c]
(因为设置了\LTleft
)然后将其设置\setlength\LTleft{-3cm}
在桌子前面,它将向左移动。