\documentclass[a4paper,12pt]{article}
\usepackage{longtable}
\usepackage{pdflscape}
\usepackage{graphicx}
\begin{document}
\begin{landscape}
% \resizebox{\textwidth}{!}{ }
\begin{longtable}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|}
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! & A & very & wide & and & long & table & here & ! \\
\hline
\end{longtable}
\end{landscape}
\end{document}
我想使用 \resizebox{\textwidth}{!} 之类的东西将长表缩小到页面宽度。它应该缩放整个表,而不仅仅是单元格的填充/边距。
答案1
这个问题和你昨天发布的问题非常相似,如何使横向多页表适合文本宽度。因此,我在此处提供的答案也适用于您重新编写的示例。(据我所知,这两个 MWE 之间的主要区别在于,第一部分包含一个 15 列表,而第二部分包含一个 24 列表。)
对于您的新示例,请注意,如果您同时指定12pt
和a4paper
选项(以及四周 1 英寸的边距),则文本块中根本没有足够的空间来容纳您的表格,而不会超过文本块的最大可用宽度。我认为,最好的办法是切换到表格的字体大小;您可以通过发出指令来11pt
实现这一点(如果主文档字体大小为) 。这是我在下面重新编写的 MWE 中所做的。12pt
\small
\documentclass[a4paper,12pt]{article}
% 1-inch margins all around -- adjust this setting to suit your needs
\usepackage[margin=1in]{geometry}
\usepackage{longtable}
\usepackage{pdflscape}
\usepackage{graphicx}
\begin{document}
\begin{landscape}
\small % Switch from 12pt to 11pt; otherwise, table won't fit
\setlength\LTleft{0pt} % default: \parindent
\setlength\LTright{0pt} % default: \fill
\begin{longtable}{@{\extracolsep{\fill}}|*{24}{c|}}
\hline
A & very & wide & and & long & table & here & ! &
A & very & wide & and & long & table & here & ! &
A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! &
A & very & wide & and & long & table & here & ! &
A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! &
A & very & wide & and & long & table & here & ! &
A & very & wide & and & long & table & here & ! \\
\hline
A & very & wide & and & long & table & here & ! &
A & very & wide & and & long & table & here & ! &
A & very & wide & and & long & table & here & ! \\
\hline
...
\hline
\end{longtable}
\end{landscape}
\end{document}
答案2
这似乎适用于你的例子
\begin{document}
\begin{landscape}
\tiny
\setlength\LTleft{0pt}
\setlength\LTright{0pt}
\begin{longtable}{@{\extracolsep{\fill}}|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|@{}}
\hline