第一篇帖子在这里,所以请温柔一点 :) 我正在写我的博士论文,在我的一个长表中发现了一个问题。基本上,第一列占用了大量未使用的空间,将最后两列推到了页边距之外。我不知道我的代码出了什么问题。下面你可以看到我的 MWE。有什么建议吗?
\documentclass[12pt,twoside,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage{caption}
\usepackage[absolute,overlay]{textpos}
\usepackage{graphicx}
\usepackage{seqsplit}
\usepackage[english]{babel}
\usepackage{rotating}
\usepackage{longtable}
\usepackage{supertabular}
\usepackage{multirow}
\usepackage{siunitx}
\usepackage{tabularx}
\usepackage{afterpage}
\usepackage{multicol}
\usepackage{epsfig}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage[version=4]{mhchem}
\usepackage[numbers]{natbib}
\usepackage{xcolor}
\usepackage{ae,aecompl}
\usepackage{graphicx}
\usepackage{inputenc}
\usepackage[T1]{fontenc}
\usepackage{epsf}
\usepackage{setspace}
\usepackage{appendix}
\renewcommand{\baselinestretch}{1.5}
\usepackage{placeins}
\setlength{\textwidth}{150mm}
\setlength{\textheight}{230mm}
\setlength{\evensidemargin}{3mm}
\setlength{\oddsidemargin}{3mm}
\begin{document}
\begin{center}
\begin{longtable}{c c c c c c c}
\caption{Calculated and measured thin film parameters.}\\
\hline
Sub-Film & $T_C$(K)&$ \Delta T_C$ (K)&$J_C (MA/cm^2)$& RRR & $\Delta$ (meV) & $L_k$ ($pH/\square$)\\
\hline
\endfirsthead
{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
\hline
Sub-Film & $T_C$ (K) & $ \Delta T_C$ (K) & $J_C (MA/cm^2)$ & RRR & $\Delta$ (meV) & $L_k$ ($pH/\square$)\\
\hline
\endhead
\hline
\endfoot
\hline
\endlastfoot
Si-NbN15-1 & 11.2 & 0.5 & 3.25 & 0.88 & 1.71 & 28.5 \\
Si-NbN15-2 & 11 & 0.47& 3.21 & 0.88 & 1.67 & 27.4 \\
Sa-NbN15 & 13.4 & 0.18& 9.3 & 1.07 & 2.03 & 7.28 \\
Sa-NbN30 & 13.9 & 0.09& n.a. & 1.09 & 2.11 & 3.33 \\
Sa-NbN5 & 12.48 & 0.27 & 2.28 & 0.96 & 1.89 & 30.33\\
SaAu-NbN13.3&13.04 & 0.3 & 6.65 & 1.11 & 1.98 & 7.57 \\
SaNb-NbN13.3&13.05 & 0.27 & 6.78 & 1.08 & 1.98 & 8.34 \\
SaAu-NbN25.5&13.53 & 0.18 & n.a. & 1.12 & 2.05 & 3.76 \\
SaNb-NbN25.5&13.295& 0.2 & n.a. & 1.1 & 2.02 & 3.96 \\
Di-NbN15 & 9.05 & 1.24 & 0.567 & 0.91 & 1.44 & 22.77\\
Di-Nb15 & 6.85 & 0.1 & n.a. & 1.79 & 1.04 & 3.25 \\
Di-Nb30 &7.27 & 0.08 & n.a. & 2.04 & 1.1 & 1.57
\label{lk}
\end{longtable}
\end{center}
\end{document}
答案1
第一列过宽的问题在于使用{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
会将整个文本放在第一列内。使用\multicolumn
as in\multicolumn{7}{c}{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
或\caption
命令 as in即可\caption{ -- \textit{Continued from previous page}} \\
。
以下 MWE 包含一些有关如何改进表格的建议。为了使单位一致并改进列内数字的对齐方式,我使用了siunitx
。为了改进水平线周围的间距,我使用了booktabs
包。为了节省一些空间并确保表格适合可用的文本宽度,我还在\thead
的命令的帮助下在列标题中引入了换行符makecell
。
\documentclass[12pt,twoside,a4paper]{report}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{amssymb}
\usepackage{siunitx}
\usepackage{makecell}
\renewcommand{\theadfont}{\normalsize}
\setlength{\textwidth}{150mm}
\setlength{\textheight}{230mm}
\setlength{\evensidemargin}{3mm}
\setlength{\oddsidemargin}{3mm}
\begin{document}
\begin{longtable}{l
S[table-format=2.3]
S[table-format=2.2]
S[table-format=2.3]
*{2}{S[table-format=1.2]}
S[table-format=2.2]}
\caption{Calculated and measured thin film parameters.}\label{lk}\\
\toprule
Sub-Film & {\thead{$T_C$\\ (\si{\K})}} & {\thead{$\Delta T_C$\\ (\si{\K})}} & {\thead{$J_C$\\ (\si{MA\per\cm\squared})}} & {\thead{RRR}} & {\thead{$\Delta$\\ (\si{\milli\electronvolt})}} & {\thead{$L_k$\\ ($pH/\square$)}}\\
\midrule
\endfirsthead
\caption{ -- \textit{Continued from previous page}} \\
\toprule
Sub-Film & {\thead{$T_C$\\ (\si{\K})}} & {\thead{$\Delta T_C$\\ (\si{\K})}} & {\thead{$J_C$\\ (\si{MA\per\cm\squared})}} & {\thead{RRR}} & {\thead{$\Delta$\\ (\si{\milli\electronvolt})}} & {\thead{$L_k$\\ ($pH/\square$)}}\\
\midrule
\endhead
\bottomrule
\endfoot
\bottomrule
\endlastfoot
Si-NbN15-1 & 11.2 & 0.5 & 3.25 & 0.88 & 1.71 & 28.5 \\
Si-NbN15-2 & 11 & 0.47& 3.21 & 0.88 & 1.67 & 27.4 \\
Sa-NbN15 & 13.4 & 0.18& 9.3 & 1.07 & 2.03 & 7.28 \\
Sa-NbN30 & 13.9 & 0.09& {n.a.} & 1.09 & 2.11 & 3.33 \\
Sa-NbN5 & 12.48 & 0.27 & 2.28 & 0.96 & 1.89 & 30.33\\
SaAu-NbN13.3&13.04 & 0.3 & 6.65 & 1.11 & 1.98 & 7.57 \\
SaNb-NbN13.3&13.05 & 0.27 & 6.78 & 1.08 & 1.98 & 8.34 \\
SaAu-NbN25.5&13.53 & 0.18 & {n.a.} & 1.12 & 2.05 & 3.76 \\
SaNb-NbN25.5&13.295& 0.2 & {n.a.} & 1.1 & 2.02 & 3.96 \\
Di-NbN15 & 9.05 & 1.24 & 0.567 & 0.91 & 1.44 & 22.77\\
Di-Nb15 & 6.85 & 0.1 & {n.a.} & 1.79 & 1.04 & 3.25 \\
Di-Nb30 &7.27 & 0.08 & {n.a.} & 2.04 & 1.1 & 1.57\\
\end{longtable}
\end{document}