假设我有一张跨多页的表格
\documentclass[DIV=8]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{booktabs,array,ragged2e,longtable}
\newcolumntype{P}[1]{>{\RaggedRight\arraybackslash}p{#1\textwidth}}
\usepackage{enumitem}
%% Create a very compact itemized list environment
\newlist{mylist}{itemize}{1}
\setlist[mylist]{label=\textbullet, nosep, wide,
leftmargin=*, % hanging indentation
before=\vspace{-0.50\baselineskip},
after =\vspace{-0.8\baselineskip}}
\begin{document}
% keep scope of longtable-related instructions local to current TeX group
\begingroup
\setlength\tabcolsep{0pt} % <--- important
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\begin{longtable}{@{\extracolsep{\fill}}P{0.38}P{0.38}P{0.2}}
\caption{My caption} \label{my-label}\\
\toprule
Column 1 & Column 2 & Column 3 \\
\midrule
\endfirsthead
\multicolumn{3}{l}{(Table \ref{my-label}, cont'd)}\\ % re-state table number
\addlinespace
\toprule
Column 1 & Column 2 & Column 3 \\
\midrule
\endhead
\bottomrule
\addlinespace
\multicolumn{3}{r}{(cont'd on next page)}\\
\endfoot
\bottomrule
\endlastfoot
\begin{mylist}
\item Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita
\item Lorem ipsum dolor sit
\item Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
\end{mylist} &
\begin{mylist}
\item Lorem ipsum dolor sit amet, consetetur sadipscing
\item Lorem ipsum dolor sit
\item Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
\item Lorem ipsum
\end{mylist} &
\begin{mylist}
\item Lorem ipsum
\item Lorem ipsum
\end{mylist} \\
\addlinespace
\begin{mylist}
\item Lorem ipsum dolor sit amet, consetetur sadipscing
\item Lorem ipsum dolor sit
\item Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
\end{mylist} &
\begin{mylist}
\item Lorem ipsum dolor sit amet, consetetur sadipscing
\item Lorem ipsum dolor sit
\item Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
\item Lorem ipsum
\item Lorem ipsum
\end{mylist} &
\begin{mylist}
\item Lorem ipsum
\item Lorem ipsum
\end{mylist} \\
\addlinespace
\begin{mylist}
\item Lorem ipsum dolor sit amet, consetetur sadipscing
\item Lorem ipsum dolor sit
\item Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
\end{mylist} &
\begin{mylist}
\item Lorem ipsum dolor sit amet, consetetur sadipscing
\item Lorem ipsum dolor sit
\item Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
\item Lorem ipsum
\item Lorem ipsum
\end{mylist} &
\begin{mylist}
\item Lorem ipsum
\item Lorem ipsum
\end{mylist} \\
\addlinespace
\begin{mylist}
\item Lorem ipsum dolor sit amet, consetetur sadipscing
\item Lorem ipsum dolor sit
\item Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
\end{mylist} &
\begin{mylist}
\item Lorem ipsum dolor sit amet, consetetur sadipscing
\item Lorem ipsum dolor sit
\item Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
\item Lorem ipsum
\item Lorem ipsum
\end{mylist} &
\begin{mylist}
\item Lorem ipsum
\item Lorem ipsum
\end{mylist} \\
%\addlinespace % omit if at page break
\begin{mylist}
\item Lorem ipsum dolor sit amet, consetetur sadipscing
\item Lorem ipsum dolor sit
\item Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
\end{mylist} &
\begin{mylist}
\item Lorem ipsum dolor sit amet, consetetur sadipscing
\item Lorem ipsum dolor sit
\item Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
\item Lorem ipsum
\item Lorem ipsum
\end{mylist} &
\begin{mylist}
\item Lorem ipsum
\item Lorem ipsum
\end{mylist} \\
\end{longtable}
\endgroup % end of TeX group that encases the 'longtable' material
\end{document}
我想将表格设置为横向模式。当我使用 时begin{landscape}
,\documentclass[DIV=8]{scrartcl}
我面临的问题是表格的“长度/深度”仅与我的文本宽度一样。这导致每页只有两行或三行...有没有办法告诉 latex 用表格覆盖文本宽度?
答案1
这使用\newgeometry
和\restoregeometry
来增加文本区域。\rule
只是为了演示可用的空间。
\documentclass[DIV=8]{scrartcl}
\usepackage{geometry}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{pdflscape}
\usepackage{afterpage}
\usepackage{booktabs,array,ragged2e,longtable}
\newcolumntype{P}[1]{>{\RaggedRight\arraybackslash}p{#1\textwidth}}
\usepackage{enumitem}
%% Create a very compact itemized list environment
\newlist{mylist}{itemize}{1}
\setlist[mylist]{label=\textbullet, nosep, wide,
leftmargin=*, % hanging indentation
before=\vspace{-0.50\baselineskip},
after =\vspace{-0.8\baselineskip}}
\usepackage{lipsum}% mwe only
\begin{document}
% keep scope of longtable-related instructions local to current TeX group
\afterpage{%
\newgeometry{textwidth={\dimexpr \textwidth+2cm}}
\begin{landscape}
\noindent\rule{\linewidth}{\textheight}% show available space
\setlength\tabcolsep{0pt} % <--- important
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\begin{longtable}{@{\extracolsep{\fill}}P{0.38}P{0.38}P{0.2}}
\caption{My caption} \label{my-label}\\
\toprule
Column 1 & Column 2 & Column 3 \\
\midrule
\endfirsthead
\multicolumn{3}{l}{(Table \ref{my-label}, cont'd)}\\ % re-state table number
\addlinespace
\toprule
Column 1 & Column 2 & Column 3 \\
\midrule
\endhead
\bottomrule
\addlinespace
\multicolumn{3}{r}{(cont'd on next page)}\\
\endfoot
\bottomrule
\endlastfoot
\begin{mylist}
\item Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita
\item Lorem ipsum dolor sit
\item Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
\end{mylist} &
\begin{mylist}
\item Lorem ipsum dolor sit amet, consetetur sadipscing
\item Lorem ipsum dolor sit
\item Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
\item Lorem ipsum
\end{mylist} &
\begin{mylist}
\item Lorem ipsum
\item Lorem ipsum
\end{mylist} \\
\addlinespace
\begin{mylist}
\item Lorem ipsum dolor sit amet, consetetur sadipscing
\item Lorem ipsum dolor sit
\item Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
\end{mylist} &
\begin{mylist}
\item Lorem ipsum dolor sit amet, consetetur sadipscing
\item Lorem ipsum dolor sit
\item Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
\item Lorem ipsum
\item Lorem ipsum
\end{mylist} &
\begin{mylist}
\item Lorem ipsum
\item Lorem ipsum
\end{mylist} \\
\addlinespace
\begin{mylist}
\item Lorem ipsum dolor sit amet, consetetur sadipscing
\item Lorem ipsum dolor sit
\item Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
\end{mylist} &
\begin{mylist}
\item Lorem ipsum dolor sit amet, consetetur sadipscing
\item Lorem ipsum dolor sit
\item Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
\item Lorem ipsum
\item Lorem ipsum
\end{mylist} &
\begin{mylist}
\item Lorem ipsum
\item Lorem ipsum
\end{mylist} \\
\addlinespace
\begin{mylist}
\item Lorem ipsum dolor sit amet, consetetur sadipscing
\item Lorem ipsum dolor sit
\item Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
\end{mylist} &
\begin{mylist}
\item Lorem ipsum dolor sit amet, consetetur sadipscing
\item Lorem ipsum dolor sit
\item Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
\item Lorem ipsum
\item Lorem ipsum
\end{mylist} &
\begin{mylist}
\item Lorem ipsum
\item Lorem ipsum
\end{mylist} \\
%\addlinespace % omit if at page break
\begin{mylist}
\item Lorem ipsum dolor sit amet, consetetur sadipscing
\item Lorem ipsum dolor sit
\item Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
\end{mylist} &
\begin{mylist}
\item Lorem ipsum dolor sit amet, consetetur sadipscing
\item Lorem ipsum dolor sit
\item Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
\item Lorem ipsum
\item Lorem ipsum
\end{mylist} &
\begin{mylist}
\item Lorem ipsum
\item Lorem ipsum
\end{mylist} \\
\end{longtable}
\end{landscape}
\restoregeometry}
\lipsum[1-8]
\end{document}