当我使用下面的代码生成文档(数据文件复制到底部)时,我的表格被正确导入。如果我更改一个单词,例如标题,然后使用 latexdiff 对两个文件进行差异分析。latexdiff fieA.tex fileB.tex > difefile.tex
如果我尝试生成具有差异的文档,我会收到以下错误:
错误:
软件包 pgfplots 警告:您请求打开表 '',但还有一个 ' .tex'。TeX 将自动附加后缀 '.tex',因此我现在将打开 '.te x'。请确保您不会意外加载 TeX 文件 - 这可能会产生不可恢复的错误。在输入行 95。
!包 pgfplots 错误:抱歉,无法从表 '' 中检索列 'NA1'。请检查拼写(或引入名称别名)。
请参阅 pgfplots 包文档以了解解释。输入 H 可立即获得帮助。...
l.95 ]\DIFaddend \dataFile
代码:
\documentclass[12pt]{article}
\usepackage{booktabs,colortbl}
\usepackage{csvsimple}
\usepackage{pgfplotstable,filecontents,booktabs}
\usepackage{longtable,lscape}
\begin{document}
\pgfplotstableread[col sep=comma]{dataFile.csv}\dataFile
\pgfplotstableset{%
begin table=\begin{longtable},
end table=\end{longtable}}
\pgfplotstabletypeset[
string type, header=false,
columns={NA1,res,sum V (e14 m3),Impr P,sum RMSE (m),Impr RMSE P},
columns/NA1/.style={column name={ },column type = {c|},string type},
columns/res/.style={column type={c|},
column name={ },precision=0,fixed,fixed zerofill},
columns/sum V (e14 m3)/.style={column name={sum V (10^{14}m^3)},
precision=4,fixed,fixed zerofill},
columns/Impr P/.style={column type={c|},
column name={Impr P},precision=4,fixed,fixed zerofill},
columns/sum RMSE (m)/.style={column name={sum RMSE (m)},
precision=1,fixed,fixed zerofill},
columns/Impr RMSE P/.style={column type={c|},
column name={Impr RMSE P},precision=1,fixed,fixed zerofill},
every head row/.style={ output empty row,
before row={\caption{\label{dataFile}Sum over...}\\
\toprule
\multicolumn{2}{c|}{} &\multicolumn{2}{c|}{Volume diff }
&\multicolumn{2}{c|}{hs rmse (m)}\\
\multicolumn{1}{c|}{} &\multicolumn{1}{c|}{res (km)}
&\multicolumn{1}{c}{sum (10$^{14}$ m$^3$)}
&\multicolumn{1}{c|}{Improvement (\,\%)} &\multicolumn{1}{c}{sum (m)}
&\multicolumn{1}{c|}{Improvement (\,\%)} \\\midrule}},
every row no 1/.style={after row=\hline},
every row no 3/.style={after row=\hline},
every row no 5/.style={after row=\hline},
every last row/.style={after row=\hline},
every even row/.style={ before row={\rowcolor{lightgray}}},
multicolumn names=c]\dataFile
\end{document}
数据文件.csv:
NA1,res,sum V (e14 m3),Impr P,sum RMSE (m),Impr RMSE P%
Base,5,1.4,,2030,
Optimal,5,1.6,-11.8,2090,-2.88
Base,10,3.1,,5260,
Optimal,10,3.2,-3.83,4850,7.95
Base,25,16,,12400,
Optimal,25,14,11.2,11100,10.4