pgfplot 表无法编译

pgfplot 表无法编译

我正在研究发现的帖子这里讨论如何将 .dat 文件导入 latex 并将其转换为表格。我的表格是longtable。我在编译代码时遇到问题,因为我收到以下错误:

“软件包 pgfplots 警告:以向后兼容模式运行(不合适的刻度标签;缺少功能)。请考虑将 \pgfplotsset{compat=1.12} 写入您的序言中。在输入行 8。”

你能帮助我正确编译我的代码吗?

这是我的代码:

\documentclass[a5paper]{article}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\usepackage{filecontents}
\usepackage{longtable}

\begin{document}

\pgfplotstableset{
begin table=\begin{longtable},
end table=\end{longtable},
}

\pgfplotstabletypeset[col sep=space,
header=true,
columns={theta_1,r2v,r3v,x,y},      % display specified columns
columns/theta_1/.style={fixed,fixed zerofill,precision=0,column type=r},
columns/r2v/.style={column type=l,string type},
columns/r3v/.style={fixed,fixed zerofill,precision=1,column type=r},
columns/x/.style={column type=l,string type},
columns/y/.style={column type=l,string type},
% requires booktabs to place horiz rules
every head row/.style={before row=\toprule, after row=\midrule\endhead},
every last row/.style={after row=\bottomrule}
]{data.dat}

\end{document}

这是我的 data.dat 文件:

theta_1    r2v    r3v      x      y
73.32513 0.08109 0.32216 1.07136 1.58646
81.52127 0.39714 0.18930 1.12726 1.54498
11.42881 0.15561 0.40579 2.00083 -0.25418
82.20383 0.26427 0.26641 0.98759 1.65272
56.91233 0.08282 0.17536 1.39728 1.09515
8.77864 0.30099 0.46950 2.07209 -0.48038
25.06484 0.13149 0.43797 2.02329 0.26017
49.21934 0.32704 0.27508 1.78136 0.81424
86.17562 0.34461 0.31124 0.95389 1.75653
86.83997 0.37408 0.29352 0.96191 1.74816
14.18518 0.22527 0.10387 1.73510 -0.29920
87.35335 0.04191 0.15062 0.60779 1.62930
86.14503 0.11449 0.23546 0.72013 1.69588
43.68381 0.45667 0.11524 1.82554 0.43447
72.02524 0.07619 0.42215 1.13327 1.65837
12.76977 0.41291 0.09738 1.76232 -0.52640
37.95852 0.26917 0.11296 1.74265 0.39662
82.41620 0.49807 0.08535 1.18931 1.44604
71.29866 0.03909 0.11383 1.02021 1.36372
86.35432 0.22134 0.21785 0.81945 1.67413
59.01666 0.05333 0.15555 1.32064 1.14392
3.21405 0.48095 0.46169 2.01803 -0.85916
76.42164 0.00232 0.21510 0.88239 1.55644
84.05939 0.38746 0.09241 1.03807 1.49802
61.08616 0.40865 0.45244 1.73304 1.27895
68.19661 0.43435 0.48987 1.59916 1.50884
66.88192 0.04222 0.21943 1.16654 1.37700
35.30043 0.19989 0.05556 1.67229 0.33875
58.99301 0.12994 0.12903 1.37311 1.08118
15.40680 0.40003 0.20436 1.88439 -0.40392
63.54415 0.21571 0.29745 1.43481 1.29929
2.86496 0.45532 0.13111 1.68131 -0.86237
24.92307 0.09092 0.30142 1.88300 0.23440
4.15543 0.13190 0.35561 1.90078 -0.48544
8.74186 0.07277 0.11087 1.68263 -0.31065
74.11120 0.06803 0.05871 0.96481 1.35119
62.53458 0.43465 0.14834 1.58297 1.04053
28.53895 0.28985 0.15939 1.83473 0.11008
85.51998 0.27493 0.21208 0.89672 1.65209
3.10015 0.07248 0.25393 1.78677 -0.46653
39.48699 0.42652 0.04276 1.77733 0.27689
34.34026 0.31103 0.13124 1.80291 0.26160
68.89651 0.17548 0.40051 1.30693 1.53810
71.56799 0.25662 0.01461 1.18879 1.20559
16.81853 0.20090 0.46443 2.08509 -0.09151
44.07880 0.03798 0.36517 1.71079 0.92168
40.10276 0.11996 0.24430 1.73094 0.66028
58.16817 0.06166 0.28926 1.41503 1.23344
63.84283 0.09195 0.11864 1.23811 1.20082
67.92180 0.11998 0.22942 1.21717 1.37797
24.84226 0.20863 0.48154 2.09624 0.20060
61.17324 0.02483 0.27340 1.30851 1.30980
58.95882 0.45136 0.26057 1.71697 1.02732
14.63506 0.47239 0.11580 1.81137 -0.52166
10.70979 0.24543 0.24445 1.85564 -0.39751
44.85276 0.24463 0.31203 1.80625 0.76074
86.37696 0.16886 0.33957 0.77410 1.79925
30.63472 0.45003 0.19776 1.94411 0.05883
52.67410 0.18462 0.18372 1.56041 0.93381
20.14307 0.05560 0.49399 2.06461 0.17615
67.61404 0.39013 0.01887 1.39416 1.07384
22.95856 0.19487 0.44258 2.06045 0.12907
45.53613 0.12085 0.45664 1.81001 0.97214
62.91691 0.20196 0.39809 1.48253 1.37938
80.18129 0.04823 0.04936 0.79541 1.43980
86.33623 0.06599 0.13094 0.65939 1.59706
49.24940 0.47103 0.16768 1.81990 0.63982
12.47620 0.47807 0.33986 2.01043 -0.54665
13.43646 0.28760 0.06828 1.71090 -0.39074
23.17574 0.02989 0.36061 1.91967 0.25628
75.66455 0.11739 0.05338 0.97433 1.35947
22.88540 0.17658 0.32688 1.94691 0.09829
73.28563 0.41060 0.24709 1.36645 1.41905
21.91725 0.00770 0.38953 1.94337 0.24543
83.63373 0.02151 0.35752 0.71488 1.79431
31.49854 0.08450 0.45186 1.96868 0.53257
17.69357 0.32456 0.44546 2.10576 -0.18323
22.59755 0.36586 0.16708 1.87258 -0.14765
55.44402 0.32387 0.34937 1.72210 1.06557
42.59600 0.22546 0.09890 1.66495 0.55888
31.64936 0.27350 0.01527 1.69479 0.14776
74.77458 0.14816 0.37204 1.10870 1.64356
52.67377 0.37235 0.25001 1.74989 0.87269
49.47512 0.09448 0.23996 1.57811 0.94661
82.54743 0.34339 0.45236 1.08023 1.83273
25.72551 0.09176 0.30493 1.88306 0.26153
68.14802 0.18424 0.30883 1.30092 1.43255
67.83562 0.31281 0.42972 1.47339 1.48888
34.24013 0.39011 0.40274 2.07231 0.34584
51.10395 0.04056 0.28836 1.53900 1.06260
6.82689 0.46469 0.09146 1.69863 -0.75815
4.85551 0.38786 0.11997 1.69344 -0.73716
47.77178 0.24340 0.44326 1.85245 0.94973
70.12505 0.21793 0.01434 1.18229 1.18817
84.06096 0.22339 0.24495 0.89063 1.66674
11.69156 0.15317 0.08396 1.68633 -0.30784
51.19413 0.25425 0.48934 1.82980 1.08773
42.24516 0.25539 0.35635 1.87903 0.69960
1.07119 0.40881 0.25024 1.77173 -0.86584
30.34104 0.39742 0.23554 1.95042 0.11336

答案1

我遇到的唯一错误是missing $ inserted由于第一列名称中的下划线。将其更改为后,theta1一切正常。

话虽如此,我不会string type特别使用最后一列,因为它有减号。相反,添加dec sep align以使数字在小数点处对齐。column name如果需要,您还可以将设置为更好的值。

在此处输入图片描述

\documentclass[a5paper]{article}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\usepackage{filecontents}
\usepackage{longtable}
\begin{filecontents*}{data.dat}
theta1    r2v    r3v      x      y
73.32513 0.08109 0.32216 1.07136 1.58646
81.52127 0.39714 0.18930 1.12726 1.54498
11.42881 0.15561 0.40579 2.00083 -0.25418
82.20383 0.26427 0.26641 0.98759 1.65272
56.91233 0.08282 0.17536 1.39728 1.09515
8.77864 0.30099 0.46950 2.07209 -0.48038
25.06484 0.13149 0.43797 2.02329 0.26017
49.21934 0.32704 0.27508 1.78136 0.81424
86.17562 0.34461 0.31124 0.95389 1.75653
86.83997 0.37408 0.29352 0.96191 1.74816
14.18518 0.22527 0.10387 1.73510 -0.29920
87.35335 0.04191 0.15062 0.60779 1.62930
86.14503 0.11449 0.23546 0.72013 1.69588
43.68381 0.45667 0.11524 1.82554 0.43447
72.02524 0.07619 0.42215 1.13327 1.65837
12.76977 0.41291 0.09738 1.76232 -0.52640
37.95852 0.26917 0.11296 1.74265 0.39662
82.41620 0.49807 0.08535 1.18931 1.44604
71.29866 0.03909 0.11383 1.02021 1.36372
86.35432 0.22134 0.21785 0.81945 1.67413
59.01666 0.05333 0.15555 1.32064 1.14392
3.21405 0.48095 0.46169 2.01803 -0.85916
76.42164 0.00232 0.21510 0.88239 1.55644
84.05939 0.38746 0.09241 1.03807 1.49802
61.08616 0.40865 0.45244 1.73304 1.27895
68.19661 0.43435 0.48987 1.59916 1.50884
66.88192 0.04222 0.21943 1.16654 1.37700
35.30043 0.19989 0.05556 1.67229 0.33875
58.99301 0.12994 0.12903 1.37311 1.08118
15.40680 0.40003 0.20436 1.88439 -0.40392
63.54415 0.21571 0.29745 1.43481 1.29929
2.86496 0.45532 0.13111 1.68131 -0.86237
24.92307 0.09092 0.30142 1.88300 0.23440
4.15543 0.13190 0.35561 1.90078 -0.48544
8.74186 0.07277 0.11087 1.68263 -0.31065
74.11120 0.06803 0.05871 0.96481 1.35119
62.53458 0.43465 0.14834 1.58297 1.04053
28.53895 0.28985 0.15939 1.83473 0.11008
85.51998 0.27493 0.21208 0.89672 1.65209
3.10015 0.07248 0.25393 1.78677 -0.46653
39.48699 0.42652 0.04276 1.77733 0.27689
34.34026 0.31103 0.13124 1.80291 0.26160
68.89651 0.17548 0.40051 1.30693 1.53810
71.56799 0.25662 0.01461 1.18879 1.20559
16.81853 0.20090 0.46443 2.08509 -0.09151
44.07880 0.03798 0.36517 1.71079 0.92168
40.10276 0.11996 0.24430 1.73094 0.66028
58.16817 0.06166 0.28926 1.41503 1.23344
63.84283 0.09195 0.11864 1.23811 1.20082
67.92180 0.11998 0.22942 1.21717 1.37797
24.84226 0.20863 0.48154 2.09624 0.20060
61.17324 0.02483 0.27340 1.30851 1.30980
58.95882 0.45136 0.26057 1.71697 1.02732
14.63506 0.47239 0.11580 1.81137 -0.52166
10.70979 0.24543 0.24445 1.85564 -0.39751
44.85276 0.24463 0.31203 1.80625 0.76074
86.37696 0.16886 0.33957 0.77410 1.79925
30.63472 0.45003 0.19776 1.94411 0.05883
52.67410 0.18462 0.18372 1.56041 0.93381
20.14307 0.05560 0.49399 2.06461 0.17615
67.61404 0.39013 0.01887 1.39416 1.07384
22.95856 0.19487 0.44258 2.06045 0.12907
45.53613 0.12085 0.45664 1.81001 0.97214
62.91691 0.20196 0.39809 1.48253 1.37938
80.18129 0.04823 0.04936 0.79541 1.43980
86.33623 0.06599 0.13094 0.65939 1.59706
49.24940 0.47103 0.16768 1.81990 0.63982
12.47620 0.47807 0.33986 2.01043 -0.54665
13.43646 0.28760 0.06828 1.71090 -0.39074
23.17574 0.02989 0.36061 1.91967 0.25628
75.66455 0.11739 0.05338 0.97433 1.35947
22.88540 0.17658 0.32688 1.94691 0.09829
73.28563 0.41060 0.24709 1.36645 1.41905
21.91725 0.00770 0.38953 1.94337 0.24543
83.63373 0.02151 0.35752 0.71488 1.79431
31.49854 0.08450 0.45186 1.96868 0.53257
17.69357 0.32456 0.44546 2.10576 -0.18323
22.59755 0.36586 0.16708 1.87258 -0.14765
55.44402 0.32387 0.34937 1.72210 1.06557
42.59600 0.22546 0.09890 1.66495 0.55888
31.64936 0.27350 0.01527 1.69479 0.14776
74.77458 0.14816 0.37204 1.10870 1.64356
52.67377 0.37235 0.25001 1.74989 0.87269
49.47512 0.09448 0.23996 1.57811 0.94661
82.54743 0.34339 0.45236 1.08023 1.83273
25.72551 0.09176 0.30493 1.88306 0.26153
68.14802 0.18424 0.30883 1.30092 1.43255
67.83562 0.31281 0.42972 1.47339 1.48888
34.24013 0.39011 0.40274 2.07231 0.34584
51.10395 0.04056 0.28836 1.53900 1.06260
6.82689 0.46469 0.09146 1.69863 -0.75815
4.85551 0.38786 0.11997 1.69344 -0.73716
47.77178 0.24340 0.44326 1.85245 0.94973
70.12505 0.21793 0.01434 1.18229 1.18817
84.06096 0.22339 0.24495 0.89063 1.66674
11.69156 0.15317 0.08396 1.68633 -0.30784
51.19413 0.25425 0.48934 1.82980 1.08773
42.24516 0.25539 0.35635 1.87903 0.69960
1.07119 0.40881 0.25024 1.77173 -0.86584
30.34104 0.39742 0.23554 1.95042 0.11336
\end{filecontents*}
\begin{document}

\pgfplotstableset{
begin table=\begin{longtable},
end table=\end{longtable},
}

\pgfplotstabletypeset[col sep=space,
header=true,
columns={theta1,r2v,r3v,x,y},      % display specified columns
columns/theta1/.style={fixed,fixed zerofill,precision=0,column type=r,column name={$\theta_1$}},
columns/r2v/.style={column type=l,precision=6,dec sep align,column name={$r_{2v}$}},
columns/r3v/.style={fixed,fixed zerofill,precision=1,column type=r,column name={$r_{3v}$}},
columns/x/.style={column type=l,precision=5,dec sep align,column name={$x$}},
columns/y/.style={column type=l,precision=5,dec sep align,column name={$y$}},
% requires booktabs to place horiz rules
every head row/.style={before row=\toprule, after row=\midrule\endhead},
every last row/.style={after row=\bottomrule}
]{data.dat}

\end{document}

相关内容