我正在尝试编译以下文档:
\documentclass{standalone}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\begin{document}
\pgfplotstabletypeset
[
every head row/.style{before row=\toprule,after row=\midrule},
every last row/.style{after row=\bottomrule},
columns/Fruit/.style={string type},
columns/Animal/.style={string type}
]
{
Number Fruit Animal
1.23456 Banana Dog
2.871 Orange Cat
3.141592 Apple Bear
} % A file can be called here too
\end{document}
但是编译会陷入无限循环,不会产生错误。我使用的是 miktex 和 texstudio。我也尝试了 overleaf,结果出现了同样的问题。
该问题似乎与以下几行有关:
every head row/.style{before row=\toprule,after row=\midrule},
every last row/.style{after row=\bottomrule},
当注释这些行时,代码可以工作,但无法插入分隔符(\toprule
,\midrule
和\bottomrule
)。
答案1
您只是忘记了=
前两个/.style
处理程序之后的内容。
\documentclass{standalone}
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.17}
\usepackage{booktabs}
\begin{document}
\pgfplotstabletypeset[
every head row/.style={before row=\toprule,after row=\midrule},
every last row/.style={after row=\bottomrule},
columns/Fruit/.style={string type},
columns/Animal/.style={string type}
]{
Number Fruit Animal
1.23456 Banana Dog
2.871 Orange Cat
3.141592 Apple Bear
}
\end{document}