我不断收到“!包数据工具错误:无法摆脱任何东西。”当使用数据工具和 siunitx 时,如果我将 S 列定义器更改为正常的居中列(因此不使用 siunitx),则文档可以正确编译。
\documentclass{article}
\usepackage{siunitx} % Provides the \SI{}{} and \si{} command for typesetting SI units
\usepackage{booktabs}
\usepackage{datatool}
\sisetup{round-mode=places,
table-number-alignment = center-decimal-marker
}
\begin{document}
\DTLloaddb{xrfWeight}{masse_xrf.csv}
\begin{table}[h]
\begin{center}
\begin{tabular}{r|S[table-format = 1.4]S[table-format = 1.4]S[table-format = 1.4]S[table-format = 1.4]S[table-format = 1.4]}
\textbf{Mesure} & \textbf{Piece 1} & \textbf{Piece 2} & \textbf{Piece 3} & \textbf{Piece 4} & \textbf{Piece 5}%
\DTLforeach*{xrfWeight}{\mesure=mesure, \prempiece=prempiece, \deuxpiece=deuxpiece, \troipiece=troipiece, \quatpiece=quatpiece, \cinqpiece=cinqpiece}{%
\DTLiffirstrow{\\\cmidrule{1-6}}{\\}%
\mesure & \prempiece & \deuxpiece & \troipiece & \quatpiece & \cinqpiece
}
\end{tabular}
\caption{Poids [g]}
\end{center}
\end{table}
\end{document}
我尝试将表格简化为只有一列且没有标题(仅 DTL 循环,仅使用 \mesure 宏)但没有任何变化......
\begin{tabular}{S[table-format = 1.4]|}
\textbf{Mesure}%
\DTLforeach*{xrfWeight}{\mesure=mesure, \prempiece=prempiece, \deuxpiece=deuxpiece, \troipiece=troipiece, \quatpiece=quatpiece, \cinqpiece=cinqpiece}{%
\\%
\mesure
}
\end{tabular}
你知道我做错了什么吗?
编辑——添加 CSV 数据:
mesure,prempiece,deuxpiece,troipiece,quatpiece,cinqpiece
1,2.9955,3.0057,3.0106,2.9693,2.9979
2,2.9951,3.0058,3.0109,2.9699,2.9978
3,2.995,3.0061,3.0108,2.9695,2.9976
4,2.995,3.0061,3.0108,2.9696,2.9977
5,2.9953,3.0057,3.0108,2.9697,2.9978
答案1
发现问题了,我需要
@{}l (or whatever column definer)
在 S 柱之后,以及
&
最后一行元素之后
在职的:
\begin{table}[h]
\begin{center}
\begin{tabular}{r|S[table-format = 1.4]S[table-format = 1.4]S[table-format = 1.4]S[table-format = 1.4]S[table-format = 1.4]@{}l}
\textbf{Mesure} & \textbf{Piece 1} & \textbf{Piece 2} & \textbf{Piece 3} & \textbf{Piece 4} & \textbf{Piece 5}%
\DTLforeach*{xrfWeight}{\mesure=mesure, \prempiece=prempiece, \deuxpiece=deuxpiece, \troipiece=troipiece, \quatpiece=quatpiece, \cinqpiece=cinqpiece}{%
\DTLiffirstrow{\\\cmidrule{1-6}}{\\}%
\mesure & \prempiece & \deuxpiece & \troipiece & \quatpiece & \cinqpiece &
}
\end{tabular}
\caption{Poids [g]}
\end{center}
\end{table}