我需要将很多数字列表放入我的文档中。我不确定如何最好地排版它们。灵感来自阅读每 5 行自动添加 \midrule前几天,我有点好奇是否可以使用 tabular 环境并自动生成换行符n数字,我可以改变n- 现在我刚刚手动创建了一个表,但我想更改n现在我必须遍历并移动所有\\
并插入额外的&
...但我完全不知道从哪里开始这个想法!这是我当前的表格:
\documentclass[12pt, a4paper, oneside, fleqn]{report}
\usepackage{geometry}
\geometry{
top=2.5cm,
left=3.5cm,
bottom=2.5cm,
right=2.5cm,
includehead,
headheight=28pt,
headsep=18pt,
showframe,
}
\usepackage{siunitx}
\usepackage{array,booktabs}
\begin{document}
\begin{tabular}{ @{} *{10}{S[table-format=4]} @{} }
16& 38& 49& 51& 55& 57& 59& 61& 63& 66 \\
70& 72& 74& 79& 81& 83& 85& 87& 89& 92 \\
95& 97& 99& 101& 104& 106& 109& 111& 113& 116 \\
119& 122& 125& 128& 131& 133& 135& 138& 141& 144 \\
146& 148& 151& 154& 157& 159& 161& 163& 167& 170 \\
173& 176& 179& 180& 185& 187& 193& 199& 205& 207 \\
210& 212& 214& 217& 219& 222& 224& 226& 230& 232 \\
236& 239& 242& 243& 246& 249& 252& 254& 260& 262 \\
265& 267& 269& 275& 280& 282& 294& 296& 299& 303 \\
306& 323& 327& 329& 335& 345& 347& 350& 354& 356 \\
360& 366& 371& 373& 375& 377& 379& 381& 383& 386 \\
389& 398& 401& 404& 407& 410& 414& 416& 426& 428 \\
432& 434& 439& 445& 457& 515& 546& 552& 559& 566 \\
571& 573& 646& 662& 668& 756& 867& 906& 921& 1027 \\
1046& 1121& 1133& 1191& 1194& 1271& 1479& 1509& 1513& 1521 \\
1536& 1574& 1579& 1585& 1587& 1626& 1639& 1643& 1652& 1658 \\
1671& 1786& 1805& 1884& 1991& 2019& 2094& 2119& 2213& 2239 \\
2245& 2271& 2321& 2398& 2701& 2741& 2819& 2889& 2907& 2910 \\
2919& 2939& 2944& 2948& 2951& 2958& 2977& 2985& 2988& 2991 \\
2993& 3002& 3008& 3014& 3027& 3029& 3036& 3047& 3049& 3053 \\
3058& 3064& 3069& 3087& 3093& 3098& 3105& 3107& 3110& 3127 \\
3136& 3151& 3160& 3165& 3168& 3175& 3178& 3207& 3228& 3244 \\
3248& 3252& 3256& 3263& 3281& 3303& 3309& 3312& 3322& 3339 \\
3375& 3378& 3411& 3438& 3440& 3442& 3444& 3446& 3448& 3450 \\
3452& 3454& 3458& 3467& 3476& 3484& 3491& 3497& 3499& 3504 \\
3506& 3509& 3518& 3522& 3527& 3540& 3555& 3575& 3577& 3580 \\
3582& 3586& 3589& 3599& 3653& 3658& 3661& 3943& 4032& 5130 \\
5368& 5371& 5379& 5381& 5383& 5397& 5399& 5401& 5403& 5405 \\
5455& 5480& 5483& 5485& 5492& 5502& 5507& 5509& 5517& 5558 \\
5988& 5992& 5994& 6003& 6350& 6463& 6601& 6962& 6980& 6982 \\
6985& 6987& 6989& 6991& 6993& 6995& 6997& 7267& 7269& 7424 \\
7426& 7428& 7885& 8007
\end{tabular}
\end{document}
我甚至不确定这是否是显示数字列表的最佳方式 - 它看起来还好吗?我认为它看起来比我插入 之前随机间隔的列表略好tabular
,并且比我尝试过的逗号分隔列表好得多。
答案1
\documentclass[12pt, a4paper, oneside, fleqn]{report}
\usepackage{geometry}
\geometry{
top=2.5cm,
left=3.5cm,
bottom=2.5cm,
right=2.5cm,
includehead,
headheight=28pt,
headsep=18pt,
showframe,
}
\def\mylist#1 {\ifx!#1\else\makebox[4em][r]{#1} \expandafter\mylist\fi}
\begin{document}
\begin{flushleft}
\mylist
16 38 49 51 55 57 59 61 63 66
70 72 74 79 81 83 85 87 89 92
95 97 99 101 104 106 109 111 113 116
119 122 125 128 131 133 135 138 141 144
146 148 151 154 157 159 161 163 167 170
173 176 179 180 185 187 193 199 205 207
210 212 214 217 219 222 224 226 230 232
236 239 242 243 246 249 252 254 260 262
265 267 269 275 280 282 294 296 299 303
306 323 327 329 335 345 347 350 354 356
360 366 371 373 375 377 379 381 383 386
389 398 401 404 407 410 414 416 426 428
432 434 439 445 457 515 546 552 559 566
571 573 646 662 668 756 867 906 921 1027
1046 1121 1133 1191 1194 1271 1479 1509 1513 1521
1536 1574 1579 1585 1587 1626 1639 1643 1652 1658
1671 1786 1805 1884 1991 2019 2094 2119 2213 2239
2245 2271 2321 2398 2701 2741 2819 2889 2907 2910
2919 2939 2944 2948 2951 2958 2977 2985 2988 2991
2993 3002 3008 3014 3027 3029 3036 3047 3049 3053
3058 3064 3069 3087 3093 3098 3105 3107 3110 3127
3136 3151 3160 3165 3168 3175 3178 3207 3228 3244
3248 3252 3256 3263 3281 3303 3309 3312 3322 3339
3375 3378 3411 3438 3440 3442 3444 3446 3448 3450
3452 3454 3458 3467 3476 3484 3491 3497 3499 3504
3506 3509 3518 3522 3527 3540 3555 3575 3577 3580
3582 3586 3589 3599 3653 3658 3661 3943 4032 5130
5368 5371 5379 5381 5383 5397 5399 5401 5403 5405
5455 5480 5483 5485 5492 5502 5507 5509 5517 5558
5988 5992 5994 6003 6350 6463 6601 6962 6980 6982
6985 6987 6989 6991 6993 6995 6997 7267 7269 7424
7426 7428 7885 8007 !
\end{flushleft}
\end{document}
答案2
如果你确定表格适合一页,那么应该这样做:
\documentclass[12pt, a4paper, oneside, fleqn]{report}
\usepackage{geometry}
\geometry{
top=2.5cm,
left=3.5cm,
bottom=2.5cm,
right=2.5cm,
includehead,
headheight=28pt,
headsep=18pt,
showframe,
}
\usepackage{xparse}
\usepackage{siunitx}
\usepackage{array,booktabs}
\ExplSyntaxOn
\NewDocumentCommand{\numberlist}{mm}
{% #1 = number of cols, #2 = number list
\fiona_number_list:nn { #1 } { #2 }
}
\seq_new:N \l_fiona_items_seq
\tl_new:N \l_fiona_table_body_tl
\int_new:N \l_fiona_column_index_int
\cs_new_protected:Npn \fiona_number_list:nn #1 #2
{
\seq_set_split:Nnn \l_fiona_items_seq { , } { #2 }
\int_zero:N \l_fiona_column_index_int
\tl_clear:N \l_fiona_table_body_tl
\seq_map_inline:Nn \l_fiona_items_seq
{
\int_incr:N \l_fiona_column_index_int
\int_compare:nTF { \l_fiona_column_index_int == #1 }
{
\tl_put_right:Nn \l_fiona_table_body_tl { \num{##1} \\ }
\int_zero:N \l_fiona_column_index_int
}
{
\tl_put_right:Nn \l_fiona_table_body_tl { \num{##1} & }
}
}
\int_compare:nF { \l_fiona_column_index_int == 0 }
{
\tl_put_right:Nn \l_fiona_table_body_tl { \\ }
}
\begin{tabular}{@{} *{#1}{r} @{}}
\l_fiona_table_body_tl
\end{tabular}
}
\ExplSyntaxOff
\begin{document}
\numberlist{10}{
16, 38, 49, 51, 55, 57, 59, 61, 63, 66,
70, 72, 74, 79, 81, 83, 85, 87, 89, 92,
95, 97, 99, 101, 104, 106, 109, 111, 113, 116,
119, 122, 125, 128, 131, 133, 135, 138, 141, 144,
146, 148, 151, 154, 157, 159, 161, 163, 167, 170,
173, 176, 179, 180, 185, 187, 193, 199, 205, 207,
210, 212, 214, 217, 219, 222, 224, 226, 230, 232,
236, 239, 242, 243, 246, 249, 252, 254, 260, 262,
265, 267, 269, 275, 280, 282, 294, 296, 299, 303,
306, 323, 327, 329, 335, 345, 347, 350, 354, 356,
360, 366, 371, 373, 375, 377, 379, 381, 383, 386,
389, 398, 401, 404, 407, 410, 414, 416, 426, 428,
432, 434, 439, 445, 457, 515, 546, 552, 559, 566,
571, 573, 646, 662, 668, 756, 867, 906, 921, 1027,
1046, 1121, 1133, 1191, 1194, 1271, 1479, 1509, 1513, 1521,
1536, 1574, 1579, 1585, 1587, 1626, 1639, 1643, 1652, 1658,
1671, 1786, 1805, 1884, 1991, 2019, 2094, 2119, 2213, 2239,
2245, 2271, 2321, 2398, 2701, 2741, 2819, 2889, 2907, 2910,
2919, 2939, 2944, 2948, 2951, 2958, 2977, 2985, 2988, 2991,
2993, 3002, 3008, 3014, 3027, 3029, 3036, 3047, 3049, 3053,
3058, 3064, 3069, 3087, 3093, 3098, 3105, 3107, 3110, 3127,
3136, 3151, 3160, 3165, 3168, 3175, 3178, 3207, 3228, 3244,
3248, 3252, 3256, 3263, 3281, 3303, 3309, 3312, 3322, 3339,
3375, 3378, 3411, 3438, 3440, 3442, 3444, 3446, 3448, 3450,
3452, 3454, 3458, 3467, 3476, 3484, 3491, 3497, 3499, 3504,
3506, 3509, 3518, 3522, 3527, 3540, 3555, 3575, 3577, 3580,
3582, 3586, 3589, 3599, 3653, 3658, 3661, 3943, 4032, 5130,
5368, 5371, 5379, 5381, 5383, 5397, 5399, 5401, 5403, 5405,
5455, 5480, 5483, 5485, 5492, 5502, 5507, 5509, 5517, 5558,
5988, 5992, 5994, 6003, 6350, 6463, 6601, 6962, 6980, 6982,
6985, 6987, 6989, 6991, 6993, 6995, 6997, 7267, 7269, 7424,
7426, 7428, 7885, 8007
}
\end{document}
\numberlist{12}{...}
这是被调用时的输出(我还添加了一个center
环境)
答案3
使用一个选项pgfplotstable
% arara: pdflatex
\documentclass{article}
\usepackage{pgfplotstable}
\begin{document}
\pgfplotstableread[
col sep=comma,
]{%
16, 38, 49, 51, 55, 57, 59, 61, 63, 66,
70, 72, 74, 79, 81, 83, 85, 87, 89, 92,
95, 97, 99, 101, 104, 106, 109, 111, 113, 116,
119, 122, 125, 128, 131, 133, 135, 138, 141, 144,
146, 148, 151, 154, 157, 159, 161, 163, 167, 170,
173, 176, 179, 180, 185, 187, 193, 199, 205, 207,
210, 212, 214, 217, 219, 222, 224, 226, 230, 232,
236, 239, 242, 243, 246, 249, 252, 254, 260, 262,
265, 267, 269, 275, 280, 282, 294, 296, 299, 303,
306, 323, 327, 329, 335, 345, 347, 350, 354, 356,
360, 366, 371, 373, 375, 377, 379, 381, 383, 386,
389, 398, 401, 404, 407, 410, 414, 416, 426, 428,
432, 434, 439, 445, 457, 515, 546, 552, 559, 566,
571, 573, 646, 662, 668, 756, 867, 906, 921, 1027,
1046, 1121, 1133, 1191, 1194, 1271, 1479, 1509, 1513, 1521,
1536, 1574, 1579, 1585, 1587, 1626, 1639, 1643, 1652, 1658,
1671, 1786, 1805, 1884, 1991, 2019, 2094, 2119, 2213, 2239,
2245, 2271, 2321, 2398, 2701, 2741, 2819, 2889, 2907, 2910,
2919, 2939, 2944, 2948, 2951, 2958, 2977, 2985, 2988, 2991,
2993, 3002, 3008, 3014, 3027, 3029, 3036, 3047, 3049, 3053,
3058, 3064, 3069, 3087, 3093, 3098, 3105, 3107, 3110, 3127,
3136, 3151, 3160, 3165, 3168, 3175, 3178, 3207, 3228, 3244,
3248, 3252, 3256, 3263, 3281, 3303, 3309, 3312, 3322, 3339,
3375, 3378, 3411, 3438, 3440, 3442, 3444, 3446, 3448, 3450,
3452, 3454, 3458, 3467, 3476, 3484, 3491, 3497, 3499, 3504,
3506, 3509, 3518, 3522, 3527, 3540, 3555, 3575, 3577, 3580,
3582, 3586, 3589, 3599, 3653, 3658, 3661, 3943, 4032, 5130,
5368, 5371, 5379, 5381, 5383, 5397, 5399, 5401, 5403, 5405,
5455, 5480, 5483, 5485, 5492, 5502, 5507, 5509, 5517, 5558,
5988, 5992, 5994, 6003, 6350, 6463, 6601, 6962, 6980, 6982,
6985, 6987, 6989, 6991, 6993, 6995, 6997, 7267, 7269, 7424,
7426, 7428, 7885, 8007, , , , , , ,
}{\fionasData}
\pgfplotstabletypeset[every head row/.style={output empty row}]{\fionasData}
\end{document}
这也可以与longtable
只需使用
\pgfplotstabletypeset[
every head row/.style={output empty row},
begin table=\begin{longtable},
end table=\end{longtable},
]{\fionasData}
以下是完整的 MWE
% arara: pdflatex
\documentclass{article}
\usepackage{pgfplotstable}
\usepackage{longtable}
\begin{document}
\pgfplotstableread[
col sep=comma,
]{%
16, 38, 49, 51, 55, 57, 59, 61, 63, 66,
70, 72, 74, 79, 81, 83, 85, 87, 89, 92,
95, 97, 99, 101, 104, 106, 109, 111, 113, 116,
119, 122, 125, 128, 131, 133, 135, 138, 141, 144,
146, 148, 151, 154, 157, 159, 161, 163, 167, 170,
173, 176, 179, 180, 185, 187, 193, 199, 205, 207,
210, 212, 214, 217, 219, 222, 224, 226, 230, 232,
236, 239, 242, 243, 246, 249, 252, 254, 260, 262,
265, 267, 269, 275, 280, 282, 294, 296, 299, 303,
306, 323, 327, 329, 335, 345, 347, 350, 354, 356,
360, 366, 371, 373, 375, 377, 379, 381, 383, 386,
389, 398, 401, 404, 407, 410, 414, 416, 426, 428,
432, 434, 439, 445, 457, 515, 546, 552, 559, 566,
571, 573, 646, 662, 668, 756, 867, 906, 921, 1027,
1046, 1121, 1133, 1191, 1194, 1271, 1479, 1509, 1513, 1521,
1536, 1574, 1579, 1585, 1587, 1626, 1639, 1643, 1652, 1658,
1671, 1786, 1805, 1884, 1991, 2019, 2094, 2119, 2213, 2239,
2245, 2271, 2321, 2398, 2701, 2741, 2819, 2889, 2907, 2910,
2919, 2939, 2944, 2948, 2951, 2958, 2977, 2985, 2988, 2991,
2993, 3002, 3008, 3014, 3027, 3029, 3036, 3047, 3049, 3053,
3058, 3064, 3069, 3087, 3093, 3098, 3105, 3107, 3110, 3127,
3136, 3151, 3160, 3165, 3168, 3175, 3178, 3207, 3228, 3244,
3248, 3252, 3256, 3263, 3281, 3303, 3309, 3312, 3322, 3339,
3375, 3378, 3411, 3438, 3440, 3442, 3444, 3446, 3448, 3450,
3452, 3454, 3458, 3467, 3476, 3484, 3491, 3497, 3499, 3504,
3506, 3509, 3518, 3522, 3527, 3540, 3555, 3575, 3577, 3580,
3582, 3586, 3589, 3599, 3653, 3658, 3661, 3943, 4032, 5130,
5368, 5371, 5379, 5381, 5383, 5397, 5399, 5401, 5403, 5405,
5455, 5480, 5483, 5485, 5492, 5502, 5507, 5509, 5517, 5558,
5988, 5992, 5994, 6003, 6350, 6463, 6601, 6962, 6980, 6982,
6985, 6987, 6989, 6991, 6993, 6995, 6997, 7267, 7269, 7424,
16, 38, 49, 51, 55, 57, 59, 61, 63, 66,
70, 72, 74, 79, 81, 83, 85, 87, 89, 92,
95, 97, 99, 101, 104, 106, 109, 111, 113, 116,
119, 122, 125, 128, 131, 133, 135, 138, 141, 144,
146, 148, 151, 154, 157, 159, 161, 163, 167, 170,
173, 176, 179, 180, 185, 187, 193, 199, 205, 207,
210, 212, 214, 217, 219, 222, 224, 226, 230, 232,
236, 239, 242, 243, 246, 249, 252, 254, 260, 262,
265, 267, 269, 275, 280, 282, 294, 296, 299, 303,
306, 323, 327, 329, 335, 345, 347, 350, 354, 356,
360, 366, 371, 373, 375, 377, 379, 381, 383, 386,
389, 398, 401, 404, 407, 410, 414, 416, 426, 428,
432, 434, 439, 445, 457, 515, 546, 552, 559, 566,
571, 573, 646, 662, 668, 756, 867, 906, 921, 1027,
1046, 1121, 1133, 1191, 1194, 1271, 1479, 1509, 1513, 1521,
1536, 1574, 1579, 1585, 1587, 1626, 1639, 1643, 1652, 1658,
1671, 1786, 1805, 1884, 1991, 2019, 2094, 2119, 2213, 2239,
2245, 2271, 2321, 2398, 2701, 2741, 2819, 2889, 2907, 2910,
2919, 2939, 2944, 2948, 2951, 2958, 2977, 2985, 2988, 2991,
2993, 3002, 3008, 3014, 3027, 3029, 3036, 3047, 3049, 3053,
3058, 3064, 3069, 3087, 3093, 3098, 3105, 3107, 3110, 3127,
3136, 3151, 3160, 3165, 3168, 3175, 3178, 3207, 3228, 3244,
3248, 3252, 3256, 3263, 3281, 3303, 3309, 3312, 3322, 3339,
3375, 3378, 3411, 3438, 3440, 3442, 3444, 3446, 3448, 3450,
3452, 3454, 3458, 3467, 3476, 3484, 3491, 3497, 3499, 3504,
3506, 3509, 3518, 3522, 3527, 3540, 3555, 3575, 3577, 3580,
3582, 3586, 3589, 3599, 3653, 3658, 3661, 3943, 4032, 5130,
5368, 5371, 5379, 5381, 5383, 5397, 5399, 5401, 5403, 5405,
5455, 5480, 5483, 5485, 5492, 5502, 5507, 5509, 5517, 5558,
5988, 5992, 5994, 6003, 6350, 6463, 6601, 6962, 6980, 6982,
6985, 6987, 6989, 6991, 6993, 6995, 6997, 7267, 7269, 7424,
7426, 7428, 7885, 8007, , , , , , ,
}{\fionasData}
\pgfplotstabletypeset[
every head row/.style={output empty row},
begin table=\begin{longtable},
end table=\end{longtable},
]{\fionasData}
\end{document}
答案4
LaTeX 解决方案
\documentclass[12pt, a4paper, oneside, fleqn]{report}
\usepackage{geometry}
\geometry{
top=2.5cm,
left=3.5cm,
bottom=2.5cm,
right=2.5cm,
includehead,
headheight=28pt,
headsep=18pt,
showframe,
}
\usepackage{array,booktabs}
\makeatletter
\newcount\tabnums@num
\newcommand{\tabnums}[2]{
\tabnums@num=0
\gdef\tabnums@body{}
\@for\@i:={#2}\do{%
\advance\tabnums@num by 1\relax%
\ifnum\tabnums@num=#1\relax%
\xdef\tabnums@body{\tabnums@body\@i \cr}%
\tabnums@num=0\relax%
\else%
\xdef\tabnums@body{\tabnums@body\@i &}%
\fi%
}%
\begin{tabular}{@{} *{#1}{r} @{}}
\tabnums@body\relax
\end{tabular}
}
\makeatother
\begin{document}
\tabnums{12}{
16, 38, 49, 51, 55, 57, 59, 61, 63, 66, 70, 72, 74, 79, 81, 83, 85, 87, 89, 92,
95, 97, 99, 101, 104, 106, 109, 111, 113, 116,
119, 122, 125, 128, 131, 133, 135, 138, 141, 144,
146, 148, 151, 154, 157, 159, 161, 163, 167, 170,
173, 176, 179, 180, 185, 187, 193, 199, 205, 207,
210, 212, 214, 217, 219, 222, 224, 226, 230, 232,
236, 239, 242, 243, 246, 249, 252, 254, 260, 262,
265, 267, 269, 275, 280, 282, 294, 296, 299, 303,
306, 323, 327, 329, 335, 345, 347, 350, 354, 356,
360, 366, 371, 373, 375, 377, 379, 381, 383, 386,
389, 398, 401, 404, 407, 410, 414, 416, 426, 428,
432, 434, 439, 445, 457, 515, 546, 552, 559, 566,
571, 573, 646, 662, 668, 756, 867, 906, 921, 1027,
1046, 1121, 1133, 1191, 1194, 1271, 1479, 1509, 1513, 1521,
1536, 1574, 1579, 1585, 1587, 1626, 1639, 1643, 1652, 1658,
1671, 1786, 1805, 1884, 1991, 2019, 2094, 2119, 2213, 2239,
2245, 2271, 2321, 2398, 2701, 2741, 2819, 2889, 2907, 2910,
2919, 2939, 2944, 2948, 2951, 2958, 2977, 2985, 2988, 2991,
2993, 3002, 3008, 3014, 3027, 3029, 3036, 3047, 3049, 3053,
3058, 3064, 3069, 3087, 3093, 3098, 3105, 3107, 3110, 3127,
3136, 3151, 3160, 3165, 3168, 3175, 3178, 3207, 3228, 3244,
3248, 3252, 3256, 3263, 3281, 3303, 3309, 3312, 3322, 3339,
3375, 3378, 3411, 3438, 3440, 3442, 3444, 3446, 3448, 3450,
3452, 3454, 3458, 3467, 3476, 3484, 3491, 3497, 3499, 3504,
3506, 3509, 3518, 3522, 3527, 3540, 3555, 3575, 3577, 3580,
3582, 3586, 3589, 3599, 3653, 3658, 3661, 3943, 4032, 5130,
5368, 5371, 5379, 5381, 5383, 5397, 5399, 5401, 5403, 5405,
5455, 5480, 5483, 5485, 5492, 5502, 5507, 5509, 5517, 5558,
5988, 5992, 5994, 6003, 6350, 6463, 6601, 6962, 6980, 6982,
6985, 6987, 6989, 6991, 6993, 6995, 6997, 7267, 7269, 7424,
7426, 7428, 7885, 8007}
\end{document}