我正在写一个长表,但长表的内容是单独写的。我该如何正确嵌入才能工作。请运行代码以查看不言自明的问题。
\documentclass[12pt]{article}
\usepackage{longtable}
\usepackage{array}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcommand{\HRule}{\rule{\linewidth}{0.5mm}}
\makeatletter
\newcommand{\testfileexists}[1]{%
\IfFileExists{#1}%
{\def\inputtestedfile{\@@input #1 }}
{\let\inputtestedfile\@empty}%
}
\makeatother
\usepackage{filecontents}
\begin{filecontents*}{TR2.1}
\begin{small}\begin{tabular}{|l|C{2cm}|C{2cm}|C{2cm}|C{2cm}|}
\hline
&\textbf{Min. [mm]}&\textbf{Max. [mm]}&\textbf{Mean [mm]}&\textbf{deviation [mm]}\\\hline
\textbf{01.07.2014}&-0.134&-0.051&-0.104&0.019\\\hline
\textbf{08.07.2014}&-0.147&-0.101&-0.136&0.010\\\hline
\textbf{15.07.2014}&-0.172&-0.101&-0.142&0.018\\\hline
\textbf{22.07.2014}&-0.182&-0.142&-0.169&0.010\\\hline
\textbf{29.07.2014}&-0.191&-0.156&-0.180&0.009\\\hline
\textbf{05.08.2014}&-0.196&-0.161&-0.183&0.008\\\hline
\textbf{12.08.2014}&-0.189&-0.171&-0.183&0.004\\\hline
\textbf{19.08.2014}&-0.188&-0.165&-0.180&0.005\\\hline
\textbf{26.08.2014}&-0.186&-0.148&-0.177&0.008\\\hline
\textbf{02.09.2014}&-0.189&-0.161&-0.179&0.006\\\hline
\textbf{09.09.2014}&-0.186&-0.170&-0.180&0.003\\\hline
\textbf{16.09.2014}&-0.188&-0.172&-0.182&0.004\\\hline
\textbf{23.09.2014}&-0.187&-0.172&-0.179&0.003\\\hline
\textbf{30.09.2014}&-0.185&-0.175&-0.181&0.002\\\hline
\textbf{07.10.2014}&-0.184&-0.175&-0.179&0.002\\\hline
\textbf{14.10.2014}&-0.182&-0.173&-0.179&0.002\\\hline
\textbf{21.10.2014}&-0.184&-0.175&-0.179&0.002\\\hline
\textbf{28.10.2014}&-0.183&-0.173&-0.178&0.002\\\hline
\textbf{04.11.2014}&-0.182&-0.174&-0.179&0.002\\\hline
\textbf{11.11.2014}&-0.178&-0.174&-0.176&0.001\\\hline
\textbf{18.11.2014}&-0.178&-0.173&-0.176&0.001\\\hline
\textbf{25.11.2014}&-0.180&-0.176&-0.177&0.001\\\hline
\textbf{02.12.2014}&-0.177&-0.172&-0.175&0.002\\\hline
\textbf{09.12.2014}&-0.179&-0.174&-0.176&0.001\\\hline
\textbf{16.12.2014}&-0.180&-0.173&-0.176&0.002\\\hline
\textbf{23.12.2014}&-0.183&-0.177&-0.180&0.002\\\hline
\textbf{30.12.2014}&-0.178&-0.175&-0.177&0.001\\\hline
\textbf{06.01.2015}&-0.182&-0.173&-0.177&0.002\\\hline
\textbf{13.01.2015}&-0.181&-0.175&-0.178&0.002\\\hline
\textbf{20.01.2015}&-0.179&-0.173&-0.175&0.002\\\hline
\textbf{27.01.2015}&-0.176&-0.172&-0.175&0.001\\\hline
\textbf{03.02.2015}&-0.177&-0.172&-0.174&0.001\\\hline
\textbf{10.02.2015}&-0.178&-0.170&-0.175&0.002\\\hline
\textbf{17.02.2015}&-0.176&-0.168&-0.174&0.002\\\hline
\textbf{24.02.2015}&-0.178&-0.170&-0.174&0.002\\\hline
\textbf{03.03.2015}&-0.177&-0.162&-0.173&0.003\\\hline
\textbf{10.03.2015}&-0.181&-0.169&-0.176&0.003\\\hline
\textbf{17.03.2015}&-0.179&-0.163&-0.174&0.004\\\hline
\textbf{24.03.2015}&-0.178&-0.158&-0.174&0.004\\\hline
\textbf{31.03.2015}&-0.178&-0.152&-0.172&0.006\\\hline
\textbf{07.04.2015}&-0.183&-0.138&-0.171&0.010\\\hline
\textbf{14.04.2015}&-0.183&-0.139&-0.171&0.012\\\hline
\textbf{21.04.2015}&-0.182&-0.143&-0.172&0.009\\\hline
\textbf{28.04.2015}&-0.184&-0.144&-0.170&0.009\\\hline
\textbf{05.05.2015}&-0.185&-0.146&-0.176&0.008\\\hline
\textbf{12.05.2015}&-0.186&-0.155&-0.176&0.008\\\hline
\textbf{19.05.2015}&-0.183&-0.146&-0.172&0.008\\\hline
\textbf{26.05.2015}&-0.183&-0.154&-0.174&0.007\\\hline
\textbf{02.06.2015}&-0.190&-0.102&-0.172&0.016\\\hline
\textbf{09.06.2015}&-0.191&-0.132&-0.175&0.015\\\hline
\textbf{16.06.2015}&-0.186&-0.154&-0.179&0.007\\\hline
\textbf{23.06.2015}&-0.187&-0.132&-0.173&0.013\\\hline
\textbf{30.06.2015}&-0.201&-0.126&-0.175&0.019\\\hline
\textbf{07.07.2015}&-0.196&-0.151&-0.185&0.010\\\hline
\textbf{14.07.2015}&-0.193&-0.140&-0.180&0.012\\\hline
\textbf{21.07.2015}&-0.193&-0.162&-0.182&0.007\\\hline
\textbf{28.07.2015}&-0.186&-0.104&-0.170&0.021\\\hline
\textbf{04.08.2015}&-0.191&-0.122&-0.172&0.016\\\hline
\textbf{11.08.2015}&-0.189&-0.156&-0.181&0.008\\\hline
\textbf{18.08.2015}&-0.191&-0.147&-0.178&0.011\\\hline
\textbf{25.08.2015}&-0.188&-0.137&-0.175&0.012\\\hline
\textbf{01.09.2015}&-0.192&-0.153&-0.182&0.009\\\hline
\end{tabular}
\end{small}
\end{filecontents*}
\begin{document}
\begin{center}
\begin{longtable}{|c|c|}
\caption{A simple longtable example}\\
\hline
\endfirsthead
\multicolumn{2}{c}%
{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
\hline
\endhead
\hline \multicolumn{2}{r}{\textit{Continued on next page}} \\
\endfoot
\hline
\endlastfoot
R1&\input{TR2.1}\\
\end{longtable}
\end{center}
\end{document}
答案1
设置的规则R1
对我来说相当不清楚,是吗R2
?R3
第二页呢。也许可以将其添加到表格的标题或标题中。或者可以将其作为单独的行添加到数据行上方。
这是没有的表格版本R1
,但在我看来格式更漂亮。
无论如何,数据行应该在顶层。TeX 只能在行之间拆分顶层表格。表格单元格,即使它包含另一个表格,也是不可拆分的对象。
\documentclass{article}
\usepackage{array}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{siunitx}
\begin{document}
\begingroup
\small
\newcommand*{\headmm}{\textbf{[mm]}}
\begin{longtable}{
>{\bfseries}l
*{3}{S[table-format=-1.3]}
S[table-format=1.3]
}
\caption{A simple longtable example}\\
\toprule
\textbf{Date} & {\bfseries Min.} & {\bfseries Max.} &
{\bfseries Mean} & {\bfseries Deviation} \\
& {\headmm} & {\headmm} & {\headmm} & {\headmm} \\
\midrule
\endfirsthead
\multicolumn{5}{c}{%
\tablename\ \thetable\ -- \textit{Continued from previous page}%
} \\
\toprule
\textbf{Date} & {\bfseries Min.} & {\bfseries Max.} &
{\bfseries Mean} & {\bfseries Deviation} \\
& {\headmm} & {\headmm} & {\headmm} & {\headmm} \\
\midrule
\endhead
\bottomrule
\multicolumn{5}{r}{\textit{Continued on next page}} \\
\endfoot
\bottomrule
\endlastfoot
01.07.2014&-0.134&-0.051&-0.104&0.019\\
08.07.2014&-0.147&-0.101&-0.136&0.010\\
15.07.2014&-0.172&-0.101&-0.142&0.018\\
22.07.2014&-0.182&-0.142&-0.169&0.010\\
29.07.2014&-0.191&-0.156&-0.180&0.009\\
05.08.2014&-0.196&-0.161&-0.183&0.008\\
12.08.2014&-0.189&-0.171&-0.183&0.004\\
19.08.2014&-0.188&-0.165&-0.180&0.005\\
26.08.2014&-0.186&-0.148&-0.177&0.008\\
02.09.2014&-0.189&-0.161&-0.179&0.006\\
09.09.2014&-0.186&-0.170&-0.180&0.003\\
16.09.2014&-0.188&-0.172&-0.182&0.004\\
23.09.2014&-0.187&-0.172&-0.179&0.003\\
30.09.2014&-0.185&-0.175&-0.181&0.002\\
07.10.2014&-0.184&-0.175&-0.179&0.002\\
14.10.2014&-0.182&-0.173&-0.179&0.002\\
21.10.2014&-0.184&-0.175&-0.179&0.002\\
28.10.2014&-0.183&-0.173&-0.178&0.002\\
04.11.2014&-0.182&-0.174&-0.179&0.002\\
11.11.2014&-0.178&-0.174&-0.176&0.001\\
18.11.2014&-0.178&-0.173&-0.176&0.001\\
25.11.2014&-0.180&-0.176&-0.177&0.001\\
02.12.2014&-0.177&-0.172&-0.175&0.002\\
09.12.2014&-0.179&-0.174&-0.176&0.001\\
16.12.2014&-0.180&-0.173&-0.176&0.002\\
23.12.2014&-0.183&-0.177&-0.180&0.002\\
30.12.2014&-0.178&-0.175&-0.177&0.001\\
06.01.2015&-0.182&-0.173&-0.177&0.002\\
13.01.2015&-0.181&-0.175&-0.178&0.002\\
20.01.2015&-0.179&-0.173&-0.175&0.002\\
27.01.2015&-0.176&-0.172&-0.175&0.001\\
03.02.2015&-0.177&-0.172&-0.174&0.001\\
10.02.2015&-0.178&-0.170&-0.175&0.002\\
17.02.2015&-0.176&-0.168&-0.174&0.002\\
24.02.2015&-0.178&-0.170&-0.174&0.002\\
03.03.2015&-0.177&-0.162&-0.173&0.003\\
10.03.2015&-0.181&-0.169&-0.176&0.003\\
17.03.2015&-0.179&-0.163&-0.174&0.004\\
24.03.2015&-0.178&-0.158&-0.174&0.004\\
31.03.2015&-0.178&-0.152&-0.172&0.006\\
07.04.2015&-0.183&-0.138&-0.171&0.010\\
14.04.2015&-0.183&-0.139&-0.171&0.012\\
21.04.2015&-0.182&-0.143&-0.172&0.009\\
28.04.2015&-0.184&-0.144&-0.170&0.009\\
05.05.2015&-0.185&-0.146&-0.176&0.008\\
12.05.2015&-0.186&-0.155&-0.176&0.008\\
19.05.2015&-0.183&-0.146&-0.172&0.008\\
26.05.2015&-0.183&-0.154&-0.174&0.007\\
02.06.2015&-0.190&-0.102&-0.172&0.016\\
09.06.2015&-0.191&-0.132&-0.175&0.015\\
16.06.2015&-0.186&-0.154&-0.179&0.007\\
23.06.2015&-0.187&-0.132&-0.173&0.013\\
30.06.2015&-0.201&-0.126&-0.175&0.019\\
07.07.2015&-0.196&-0.151&-0.185&0.010\\
14.07.2015&-0.193&-0.140&-0.180&0.012\\
21.07.2015&-0.193&-0.162&-0.182&0.007\\
28.07.2015&-0.186&-0.104&-0.170&0.021\\
04.08.2015&-0.191&-0.122&-0.172&0.016\\
11.08.2015&-0.189&-0.156&-0.181&0.008\\
18.08.2015&-0.191&-0.147&-0.178&0.011\\
25.08.2015&-0.188&-0.137&-0.175&0.012\\
01.09.2015&-0.192&-0.153&-0.182&0.009\\
\end{longtable}
\endgroup
\end{document}
第 1 页:
第2页: