编辑:感谢 David Carlisle 在下面的评论中指出了这个问题。我决定更正 MWE 并添加一些评论来帮助任何
longtable
第一次使用的人。
首先,是的 - 我用 Google 搜索过,也确实找到了一些与longtable
plus相关的问题siunitx
- 但说实话?这对我来说没什么意义,我又回到了原点!
我制作了一个表格,在编译后发现它对于单个页面来说太大了。起初,我想在另一个页面中再制作一个表格,但我意识到我见过表格生成两个或更多页面,所以我选择了“不那么笨拙”方法——来longtable
救援吧!
当然,在看过一些示例并尝试理解手册后,我决定将其写下来并编写!结果呢?失败,一切知识之母。
所以,TeX 的大师们,如果能提供任何关于为什么以及如何运行此代码的帮助,我将不胜感激!
\documentclass[a4paper]{article}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}
\begin{longtable}{@{\hspace{\tabcolsep}\extracolsep{\fill}} cccccc S[table-format=5.4] S[table-format=-1.4] } %set number of columns
\caption{Measured rotational transitions (in MHz) assigned to conformer $I$ using CP-FTMW spectroscopy.} \\
% First page Table Header setup
\toprule
{J\textasciiacute} & {K\textasciiacute$_{-1}$} & {K\textasciiacute$_{+1}$} & {J\textacutedbl} & {K\textacutedbl$_{-1}$} & {K\textacutedbl$_{+1} $} & {$ \nu_{obs} $} & {$ \nu_{obs} - \nu_{cal} $} \\
\midrule
\endfirsthead
% *// END //*
% Second page Table Header setup
\multicolumn{8}{c}%
{{\tablename\ \thetable{} -- resuming from previous page}} \\
\midrule
{J\textasciiacute} & {K\textasciiacute$_{-1}$} & {K\textasciiacute$_{+1}$} & {J\textacutedbl} & {K\textacutedbl$_{-1}$} & {K\textacutedbl$_{+1} $} & {$ \nu_{obs} $} & {$ \nu_{obs} - \nu_{cal} $} \\
\midrule
\endhead
% *// END //*
% Table Break Footnote Setup
\midrule
\multicolumn{8}{c}{{Resumed on next page}}
\endfoot
\bottomrule
\endlastfoot
% *// END //*
7 & 0 & 7 & 6 & 0 & 6 & 6079.960 & -0.001 \\
8 & 0 & 8 & 7 & 0 & 7 & 6923.244 & 0.056 \\
10 & 0 & 10 & 9 & 0 & 9 & 8588.202 & 0.047 \\
11 & 0 & 11 & 10 & 0 & 10 & 9412.244 & 0.038 \\
7 & 1 & 6 & 6 & 1 & 5 & 6337.229 & 0.027 \\
8 & 1 & 7 & 7 & 1 & 6 & 7233.906 & 0.021 \\
9 & 1 & 8 & 8 & 1 & 7 & 8126.661 & 0.032 \\
10 & 1 & 9 & 9 & 1 & 8 & 9014.687 & 0.032 \\
11 & 1 & 10 & 10 & 1 & 9 & 9897.147 & 0.026 \\
10 & 1 & 10 & 9 & 1 & 9 & 8464.423 & -0.012 \\
9 & 1 & 9 & 8 & 1 & 8 & 7625.732 & -0.013 \\
8 & 1 & 8 & 7 & 1 & 7 & 6785.001 & -0.003 \\
11 & 1 & 11 & 10 & 1 & 10 & 9301.098 & -0.012 \\
10 & 2 & 9 & 9 & 2 & 8 & 8761.701 & -0.007 \\
9 & 2 & 8 & 8 & 2 & 7 & 7892.425 & 0.018 \\
8 & 2 & 7 & 7 & 2 & 6 & 7020.953 & -0.012 \\
7 & 2 & 6 & 6 & 2 & 5 & 6147.569 & -0.031 \\
5 & 1 & 4 & 4 & 0 & 4 & 6491.023 & -0.027 \\
6 & 1 & 5 & 5 & 0 & 5 & 7558.030 & -0.028 \\
7 & 1 & 6 & 6 & 0 & 6 & 8666.376 & 0.020 \\
8 & 1 & 7 & 7 & 0 & 7 & 9820.300 & 0.019 \\
4 & 2 & 3 & 3 & 1 & 3 & 8652.332 & -0.033 \\
5 & 2 & 4 & 4 & 1 & 4 & 9645.484 & -0.031 \\
3 & 2 & 2 & 2 & 1 & 2 & 7687.458 & -0.017 \\
2 & 2 & 1 & 1 & 1 & 1 & 6750.755 & -0.019 \\
2 & 2 & 0 & 1 & 1 & 0 & 6695.425 & 0.032 \\
3 & 2 & 1 & 2 & 1 & 1 & 7524.271 & 0.016 \\
4 & 2 & 2 & 3 & 1 & 2 & 8333.209 & -0.009 \\
5 & 2 & 3 & 4 & 1 & 3 & 9128.076 & -0.054 \\
6 & 2 & 4 & 5 & 1 & 4 & 9916.154 & 0.002 \\
2 & 2 & 1 & 1 & 1 & 0 & 6693.956 & 0.028 \\
3 & 2 & 2 & 2 & 1 & 1 & 7516.964 & 0.027 \\
4 & 2 & 3 & 3 & 1 & 2 & 8311.325 & 0.014 \\
5 & 2 & 4 & 4 & 1 & 3 & 9077.186 & -0.033 \\
11 & 2 & 9 & 10 & 2 & 8 & 9893.710 & -0.024 \\
10 & 2 & 8 & 9 & 2 & 7 & 8971.500 & -0.023 \\
9 & 2 & 7 & 8 & 2 & 6 & 8051.888 & 0.001 \\
8 & 2 & 6 & 7 & 2 & 5 & 7136.489 & -0.008 \\
11 & 3 & 8 & 10 & 3 & 7 & 9736.928 & -0.029 \\
9 & 3 & 6 & 8 & 3 & 5 & 7948.656 & -0.006 \\
8 & 3 & 5 & 7 & 3 & 4 & 7059.430 & -0.000 \\
7 & 3 & 5 & 6 & 3 & 4 & 6169.740 & 0.030 \\
8 & 3 & 6 & 7 & 3 & 5 & 7053.534 & -0.008 \\
9 & 3 & 7 & 8 & 3 & 6 & 7937.882 & -0.051 \\
10 & 3 & 8 & 9 & 3 & 7 & 8822.755 & 0.036 \\
11 & 3 & 9 & 10 & 3 & 8 & 9707.698 & 0.018 \\
11 & 4 & 7 & 10 & 4 & 6 & 9703.309 & -0.013 \\
10 & 4 & 6 & 9 & 4 & 5 & 8817.517 & -0.026 \\
9 & 4 & 5 & 8 & 4 & 4 & 7932.918 & 0.039 \\
11 & 4 & 8 & 10 & 4 & 7 & 9702.196 & -0.055 \\
10 & 4 & 7 & 9 & 4 & 6 & 8817.017 & 0.011 \\
9 & 4 & 6 & 8 & 4 & 5 & 7932.606 & -0.024 \\
7 & 4 & 4 & 6 & 4 & 3 & 6166.219 & -0.036 \\
2 & 2 & 0 & 1 & 1 & 1 & 6752.243 & 0.005 \\
3 & 2 & 1 & 2 & 1 & 2 & 7694.798 & 0.005 \\
4 & 2 & 2 & 3 & 1 & 3 & 8674.239 & -0.033 \\
5 & 2 & 3 & 4 & 1 & 4 & 9696.521 & 0.096 \\
10 & 0 & 10 & 9 & 1 & 9 & 7859.890 & -0.006 \\
9 & 0 & 9 & 8 & 1 & 8 & 6897.479 & -0.005 \\
\end{longtable}
\end{document}
答案1
我将向您介绍 MWE 的一些小改动,这些改动能够确定表格宽度等于文本宽度,并且启用此功能\extracolsep{\fill}}
可按预期工作。此外,在S
列中,我将使用group-four-digits
选项,在每个第四个表格行后插入一些垂直空间等。所有更改在代码中都用 标记% <---
。
综上所述,表格如下:
\documentclass[a4paper]{article}
\usepackage{booktabs, longtable}
\usepackage{siunitx}
\usepackage[skip=1ex,
labelfont=bf,font=small]{caption} % <--- new
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\begin{document}
\begingroup
\sisetup{group-four-digits} % <---
\setlength\LTleft{0pt} % <---
\setlength\LTright{0pt} % <---
\setlength\LTcapwidth\linewidth % <---
\begin{longtable}{@{\hspace{\tabcolsep}\extracolsep{\fill}}
*{6}{S[table-format=2.0]} % <---
S[table-format=4.3] % <---
S[table-format=-1.3] } % <---
\caption{Measured rotational transitions (in MHz) assigned to conformer $I$ using CP-FTMW spectroscopy.}
\label{tab:spectroscopy} \\
% First page Table Header setup
\toprule
{J´} & {K$_{-1}$} & {K´$_{+1}$} & {J´} & {K´$_{-1}$} % <---
& {K´´$_{+1}$} & {$\nu_{\mathrm{obs}}$} % <---
& {$\nu_{\mathrm{obs}} - \nu_{\mathrm{cal}}$} \\ % <---
\midrule
\endfirsthead
% Second page Table Header setup
\caption[]{Measured rotational transitions -- % <---
resuming from previous page} \\
\midrule
{J´} & {K$_{-1}$} & {K´$_{+1}$} & {J´} & {K´$_{-1}$}
& {K´´$_{+1}$} & {$\nu_{\mathrm{obs}}$}
& {$\nu_{\mathrm{obs}} - \nu_{\mathrm{cal}}$} \\
\midrule
\endhead
% Table Footer setup
\midrule[\heavyrulewidth]
\multicolumn{8}{r}{\small\textit{Resumed on next page}}
\endfoot
\bottomrule
\endlastfoot
% end of longtable preamble
%
% table body
7 & 0 & 7 & 6 & 0 & 6 & 6079.960 & -0.001 \\
8 & 0 & 8 & 7 & 0 & 7 & 6923.244 & 0.056 \\
10 & 0 & 10 & 9 & 0 & 9 & 8588.202 & 0.047 \\
11 & 0 & 11 & 10 & 0 & 10 & 9412.244 & 0.038 \\
\addlinespace
7 & 1 & 6 & 6 & 1 & 5 & 6337.229 & 0.027 \\
8 & 1 & 7 & 7 & 1 & 6 & 7233.906 & 0.021 \\
9 & 1 & 8 & 8 & 1 & 7 & 8126.661 & 0.032 \\
10 & 1 & 9 & 9 & 1 & 8 & 9014.687 & 0.032 \\
\addlinespace
11 & 1 & 10 & 10 & 1 & 9 & 9897.147 & 0.026 \\
10 & 1 & 10 & 9 & 1 & 9 & 8464.423 & -0.012 \\
9 & 1 & 9 & 8 & 1 & 8 & 7625.732 & -0.013 \\
8 & 1 & 8 & 7 & 1 & 7 & 6785.001 & -0.003 \\
\addlinespace
11 & 1 & 11 & 10 & 1 & 10 & 9301.098 & -0.012 \\
10 & 2 & 9 & 9 & 2 & 8 & 8761.701 & -0.007 \\
9 & 2 & 8 & 8 & 2 & 7 & 7892.425 & 0.018 \\
8 & 2 & 7 & 7 & 2 & 6 & 7020.953 & -0.012 \\
\addlinespace
7 & 2 & 6 & 6 & 2 & 5 & 6147.569 & -0.031 \\
5 & 1 & 4 & 4 & 0 & 4 & 6491.023 & -0.027 \\
6 & 1 & 5 & 5 & 0 & 5 & 7558.030 & -0.028 \\
7 & 1 & 6 & 6 & 0 & 6 & 8666.376 & 0.020 \\
\addlinespace
8 & 1 & 7 & 7 & 0 & 7 & 9820.300 & 0.019 \\
4 & 2 & 3 & 3 & 1 & 3 & 8652.332 & -0.033 \\
5 & 2 & 4 & 4 & 1 & 4 & 9645.484 & -0.031 \\
3 & 2 & 2 & 2 & 1 & 2 & 7687.458 & -0.017 \\
\addlinespace
2 & 2 & 1 & 1 & 1 & 1 & 6750.755 & -0.019 \\
2 & 2 & 0 & 1 & 1 & 0 & 6695.425 & 0.032 \\
3 & 2 & 1 & 2 & 1 & 1 & 7524.271 & 0.016 \\
4 & 2 & 2 & 3 & 1 & 2 & 8333.209 & -0.009 \\
\addlinespace
5 & 2 & 3 & 4 & 1 & 3 & 9128.076 & -0.054 \\
6 & 2 & 4 & 5 & 1 & 4 & 9916.154 & 0.002 \\
2 & 2 & 1 & 1 & 1 & 0 & 6693.956 & 0.028 \\
3 & 2 & 2 & 2 & 1 & 1 & 7516.964 & 0.027 \\
\addlinespace
4 & 2 & 3 & 3 & 1 & 2 & 8311.325 & 0.014 \\
5 & 2 & 4 & 4 & 1 & 3 & 9077.186 & -0.033 \\
11 & 2 & 9 & 10 & 2 & 8 & 9893.710 & -0.024 \\
10 & 2 & 8 & 9 & 2 & 7 & 8971.500 & -0.023 \\
\addlinespace
9 & 2 & 7 & 8 & 2 & 6 & 8051.888 & 0.001 \\
8 & 2 & 6 & 7 & 2 & 5 & 7136.489 & -0.008 \\
11 & 3 & 8 & 10 & 3 & 7 & 9736.928 & -0.029 \\
9 & 3 & 6 & 8 & 3 & 5 & 7948.656 & -0.006 \\
\addlinespace
8 & 3 & 5 & 7 & 3 & 4 & 7059.430 & -0.000 \\
7 & 3 & 5 & 6 & 3 & 4 & 6169.740 & 0.030 \\
8 & 3 & 6 & 7 & 3 & 5 & 7053.534 & -0.008 \\
9 & 3 & 7 & 8 & 3 & 6 & 7937.882 & -0.051 \\
\addlinespace
10 & 3 & 8 & 9 & 3 & 7 & 8822.755 & 0.036 \\
11 & 3 & 9 & 10 & 3 & 8 & 9707.698 & 0.018 \\
11 & 4 & 7 & 10 & 4 & 6 & 9703.309 & -0.013 \\
10 & 4 & 6 & 9 & 4 & 5 & 8817.517 & -0.026 \\
\addlinespace
9 & 4 & 5 & 8 & 4 & 4 & 7932.918 & 0.039 \\
11 & 4 & 8 & 10 & 4 & 7 & 9702.196 & -0.055 \\
10 & 4 & 7 & 9 & 4 & 6 & 8817.017 & 0.011 \\
9 & 4 & 6 & 8 & 4 & 5 & 7932.606 & -0.024 \\
\addlinespace
7 & 4 & 4 & 6 & 4 & 3 & 6166.219 & -0.036 \\
2 & 2 & 0 & 1 & 1 & 1 & 6752.243 & 0.005 \\
3 & 2 & 1 & 2 & 1 & 2 & 7694.798 & 0.005 \\
4 & 2 & 2 & 3 & 1 & 3 & 8674.239 & -0.033 \\
\addlinespace
5 & 2 & 3 & 4 & 1 & 4 & 9696.521 & 0.096 \\
10 & 0 & 10 & 9 & 1 & 9 & 7859.890 & -0.006 \\
9 & 0 & 9 & 8 & 1 & 8 & 6897.479 & -0.005 \\
\end{longtable}
\endgroup
\end{document}
上述 MWE 给出: