如何固定 longtable 的宽度 LATEX

5

我想设置我的 longtable 的宽度,使其适合页面而不会裁剪。我有206列和17行。

我使用 tablesgenerator.com 获取我的 longtable,但选项“将表格缩放到文本宽度”在 longtable 中不起作用,需要一些帮助。(我是LaTeX初学者)。

\documentclass{article}
\usepackage{longtable}
\usepackage{booktabs}

\begin{document}

\begin{longtable}{@{}lllllllllllllllll@{}}
\toprule
\textbf{SN} & \textbf{zhelio} & \textbf{zhelio\_un} & \textbf{zCMB} & 
\textbf{zCMB\_un} & \textbf{Peak\_MJD} & \textbf{Peak\_MJD\_un} & \textbf{x1} 
& \textbf{x1\_un} & \textbf{c} & \textbf{c\_un} & \textbf{mB} & 
\textbf{mB\_un} & \textbf{t} & \textbf{t\_un} & \textbf{Host\_logmass} & 
\textbf{Host\_logmass\_un} \\* \midrule
\endhead

%table stuff here...

\caption{}
\label{tab:my-table}\\
\end{longtable}

\end{document}

这就是它的外观

图片


2
206列数据怎么可能放在一张纸上啊???????? - samcarter_is_at_topanswers.xyz
即使你问题中的代码有17列,也无法适合普通大小的纸张。 - samcarter_is_at_topanswers.xyz
我有一个巨大的数据文件需要包含在我的作业中。但是,206列实在太多了,这就是为什么我需要帮助来弄清楚如何让它们全部适合。如果需要5页长也没关系,宽度只需要缩小或者做些其他调整即可。 - Landberg
你是不是指的是206行? - samcarter_is_at_topanswers.xyz
也许,说实话我不知道行和列之间的区别 :) 但它有205个单元格长和17个单元格宽。 - Landberg
1个回答

1
假设您指的是206行而不是列,则可以尝试以下策略:
  • 将表格放在横向页面上

  • 使用较小的字体

  • 减少文档边距以获得更多空间

  • 减少列之间的间距


\documentclass{article}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage[vmargin=2cm]{geometry}
\usepackage{lscape}

\begin{document}

\begin{landscape}
\small
\setlength{\tabcolsep}{2pt}
\begin{longtable}{@{}lllllllllllllllll@{}}
\toprule
\textbf{SN} & \textbf{zhelio} & \textbf{zhelio\_un} & \textbf{zCMB} & 
\textbf{zCMB\_un} & \textbf{Peak\_MJD} & \textbf{Peak\_MJD\_un} & \textbf{x1} 
& \textbf{x1\_un} & \textbf{c} & \textbf{c\_un} & \textbf{mB} & 
\textbf{mB\_un} & \textbf{t} & \textbf{t\_un} & \textbf{Host\_logmass} & 
\textbf{Host\_logmass\_un} \\* \midrule
\endhead

%table stuff here...

\caption{}
\label{tab:my-table}\\
\end{longtable}
\end{landscape}
\end{document}

enter image description here


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接