在提供的解决方案中这里经过埃格尔如果数据更大,那么如何将数据分成三列:
这是他的代码:
\documentclass[a4paper]{book}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{siunitx}
\usepackage{xparse}
\usepackage{filecontents}
\ExplSyntaxOn
\ior_new:N \g_joe_file_stream
\tl_new:N \l__joe_file_body_tl
\int_new:N \l__joe_file_rows_int
\NewDocumentCommand{\readfile}{smm}
{% * = keep header, #2 = file name, #3 = symbolic name
\seq_clear_new:c { l_joe_file_#3_seq }
\ior_open:Nn \g_joe_file_stream { #2 }
\ior_map_inline:Nn \g_joe_file_stream
{
\seq_put_right:cn { l_joe_file_#3_seq } { ##1 }
}
\IfBooleanF{#1}{ \seq_pop_left:cN { l_joe_file_#3_seq } \l_tmpa_tl }
}
\NewDocumentCommand{\processdata}{mmmm}
{% #1 = name in, #2 = name out, #3 = code in, #4 = code out
\seq_clear_new:c { l_joe_file_#2_seq } % the output sequence
\cs_set:Npn \__joe_file_process:w #3 { #4 }
\seq_set_map:ccn { l_joe_file_#2_seq } { l_joe_file_#1_seq } { \__joe_file_process:w ##1 }
}
\cs_generate_variant:Nn \seq_set_map:NNn { cc }
\NewDocumentCommand{\maketable}{mmmm}
{% #1 = cols, #2 = table preamble, #3 = headers, #4 = data set
\tl_clear:N \l__joe_file_body_tl
\int_set:Nn \l__joe_file_rows_int
{
\int_div_truncate:nn { \seq_count:c { l_joe_file_#4_seq } + #1 - 1 } { #1 } % rounds
}
\int_step_inline:nnnn { 1 } { 1 } { \l__joe_file_rows_int }
{
\int_step_inline:nnnn { 0 } { 1 } { #1 - 1 }
{
\tl_put_right:Nx \l__joe_file_body_tl
{
\seq_item:cn { l_joe_file_#4_seq } { ##1 + ####1 * \l__joe_file_rows_int } &
}
}
\tl_put_right:Nn \l__joe_file_body_tl { \\ }
}
\begin{tabular}{ *{#1}{#2} l@{} }
\toprule
\prg_replicate:nn { #1 } { #3 & } \\
\midrule
\tl_use:N \l__joe_file_body_tl
\bottomrule
\end{tabular}
}
\ExplSyntaxOff
\usepackage{filecontents}
\begin{filecontents}{detJ.dat}
Move Det_J
1 -0.0786172
2 -0.0786075
3 -0.0785986
4 -0.0785908
5 -0.0785838
6 -0.0785778
7 -0.0785729
8 -0.0785688
9 -0.0785659
10 -0.0785639
11 -0.0785630
12 -0.0785631
13 -0.0785644
14 -0.0785667
15 -0.0785702
16 -0.0785747
17 -0.0785804
18 -0.0785873
19 -0.0785954
20 -0.0786046
21 -0.0786150
22 -0.0786267
23 -0.0786395
24 -0.0786537
25 -0.0786690
26 -0.0786857
27 -0.0787036
28 -0.0787228
29 -0.0787433
30 -0.0787651
31 -0.0787883
32 -0.0788128
33 -0.0788386
34 -0.0788658
35 -0.0788944
36 -0.0789243
37 -0.0789557
38 -0.0789884
39 -0.0790226
40 -0.0790581
41 -0.0790951
42 -0.0791335
43 -0.0791734
44 -0.0792147
45 -0.0792575
46 -0.0793017
47 -0.0793474
48 -0.0793946
49 -0.0794433
50 -0.0794934
51 -0.0795451
52 -0.0795983
53 -0.0796529
54 -0.0797091
55 -0.0797668
56 -0.0798260
57 -0.0798868
58 -0.0799490
59 -0.0800129
60 -0.0800782
61 -0.0801451
62 -0.0802135
63 -0.0802835
64 -0.0803550
65 -0.0804280
66 -0.0805026
67 -0.0805788
68 -0.0806565
69 -0.0807358
70 -0.0808166
71 -0.0808989
72 -0.0809829
73 -0.0810683
74 -0.0811553
75 -0.0812439
76 -0.0813340
77 -0.0814256
78 -0.0815188
79 -0.0816135
80 -0.0817098
81 -0.0818076
82 -0.0819069
83 -0.0820077
84 -0.0821100
85 -0.0822139
86 -0.0823193
87 -0.0824261
88 -0.0825345
89 -0.0826443
90 -0.0827557
91 -0.0828685
92 -0.0829828
93 -0.0830985
94 -0.0832157
95 -0.0833343
96 -0.0834544
97 -0.0835759
98 -0.0836988
99 -0.0838231
100 -0.0839488
101 -0.0840759
1 -0.0786172
2 -0.0786075
3 -0.0785986
4 -0.0785908
5 -0.0785838
6 -0.0785778
7 -0.0785729
8 -0.0785688
9 -0.0785659
10 -0.0785639
11 -0.0785630
12 -0.0785631
13 -0.0785644
14 -0.0785667
15 -0.0785702
16 -0.0785747
17 -0.0785804
18 -0.0785873
19 -0.0785954
20 -0.0786046
21 -0.0786150
22 -0.0786267
23 -0.0786395
24 -0.0786537
25 -0.0786690
26 -0.0786857
27 -0.0787036
28 -0.0787228
29 -0.0787433
30 -0.0787651
31 -0.0787883
32 -0.0788128
33 -0.0788386
34 -0.0788658
35 -0.0788944
36 -0.0789243
37 -0.0789557
38 -0.0789884
39 -0.0790226
40 -0.0790581
41 -0.0790951
42 -0.0791335
43 -0.0791734
44 -0.0792147
45 -0.0792575
46 -0.0793017
47 -0.0793474
48 -0.0793946
49 -0.0794433
50 -0.0794934
51 -0.0795451
52 -0.0795983
53 -0.0796529
54 -0.0797091
55 -0.0797668
56 -0.0798260
57 -0.0798868
58 -0.0799490
59 -0.0800129
60 -0.0800782
61 -0.0801451
62 -0.0802135
63 -0.0802835
64 -0.0803550
65 -0.0804280
66 -0.0805026
67 -0.0805788
68 -0.0806565
69 -0.0807358
70 -0.0808166
71 -0.0808989
72 -0.0809829
73 -0.0810683
74 -0.0811553
75 -0.0812439
76 -0.0813340
77 -0.0814256
78 -0.0815188
79 -0.0816135
80 -0.0817098
81 -0.0818076
82 -0.0819069
83 -0.0820077
84 -0.0821100
85 -0.0822139
86 -0.0823193
87 -0.0824261
88 -0.0825345
89 -0.0826443
90 -0.0827557
91 -0.0828685
92 -0.0829828
93 -0.0830985
94 -0.0832157
95 -0.0833343
96 -0.0834544
97 -0.0835759
98 -0.0836988
99 -0.0838231
100 -0.0839488
101 -0.0840759
1 -0.0786172
2 -0.0786075
3 -0.0785986
4 -0.0785908
5 -0.0785838
6 -0.0785778
7 -0.0785729
8 -0.0785688
9 -0.0785659
10 -0.0785639
11 -0.0785630
12 -0.0785631
13 -0.0785644
14 -0.0785667
15 -0.0785702
16 -0.0785747
17 -0.0785804
18 -0.0785873
19 -0.0785954
20 -0.0786046
21 -0.0786150
22 -0.0786267
23 -0.0786395
24 -0.0786537
25 -0.0786690
26 -0.0786857
27 -0.0787036
28 -0.0787228
29 -0.0787433
30 -0.0787651
31 -0.0787883
32 -0.0788128
33 -0.0788386
34 -0.0788658
35 -0.0788944
36 -0.0789243
37 -0.0789557
38 -0.0789884
39 -0.0790226
40 -0.0790581
41 -0.0790951
42 -0.0791335
43 -0.0791734
44 -0.0792147
45 -0.0792575
46 -0.0793017
47 -0.0793474
48 -0.0793946
49 -0.0794433
50 -0.0794934
51 -0.0795451
52 -0.0795983
53 -0.0796529
54 -0.0797091
55 -0.0797668
56 -0.0798260
57 -0.0798868
58 -0.0799490
59 -0.0800129
60 -0.0800782
61 -0.0801451
62 -0.0802135
63 -0.0802835
64 -0.0803550
65 -0.0804280
66 -0.0805026
67 -0.0805788
68 -0.0806565
69 -0.0807358
70 -0.0808166
71 -0.0808989
72 -0.0809829
73 -0.0810683
74 -0.0811553
75 -0.0812439
76 -0.0813340
77 -0.0814256
78 -0.0815188
79 -0.0816135
80 -0.0817098
81 -0.0818076
82 -0.0819069
83 -0.0820077
84 -0.0821100
85 -0.0822139
86 -0.0823193
87 -0.0824261
88 -0.0825345
89 -0.0826443
90 -0.0827557
91 -0.0828685
92 -0.0829828
93 -0.0830985
94 -0.0832157
95 -0.0833343
96 -0.0834544
97 -0.0835759
98 -0.0836988
99 -0.0838231
100 -0.0839488
101 -0.0840759
\end{filecontents}
\begin{document}
\begin{table}
\centering
\readfile{detJ.dat}{datain}
\processdata{datain}{dataout}{#1 #2}{#1 & #2}
\sisetup{group-digits=false}
\footnotesize
\maketable{3}{S[table-format=3.0]S[table-format=-1.7]}{{Movement}&{DetJ}}{dataout}
\end{table}
\end{document}