后弄清楚为什么我的 MCVE没有按预期工作,我想我在 babel 或 csvsimple 包中发现了一个错误。编译如下:
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{test.csv}
n,pibreal,pibnom,deflactor,c,isr,trc,tdeflactado,trcdeflactado,I,x,m
2000,1059317580733.46,393302970000,37.127956446,281965700000,10616220000,437870990000,3941585537.81615,162572550457.059,109702668399.757,139614000000,172276800000
\end{filecontents*}
\usepackage[utf8]{inputenc}
\usepackage{csvsimple}
\begin{document}
\begin{tabular}{|l|r|r|}%
\bfseries Año & \bfseries PIB & \bfseries Consumo privado%
\csvreader{test.csv}{}%
{\\ \hline \csvcoli & \csvcoliii & \csvcolv}%
\end{tabular}
\end{document}
但事实并非如此:
\documentclass{article}
\usepackage[spanish]{babel}
\usepackage{filecontents}
\begin{filecontents*}{test.csv}
n,pibreal,pibnom,deflactor,c,isr,trc,tdeflactado,trcdeflactado,I,x,m
2000,1059317580733.46,393302970000,37.127956446,281965700000,10616220000,437870990000,3941585537.81615,162572550457.059,109702668399.757,139614000000,172276800000
\end{filecontents*}
\usepackage[utf8]{inputenc}
\usepackage{csvsimple}
\begin{document}
\begin{tabular}{|l|r|r|}%
\bfseries Año & \bfseries PIB & \bfseries Consumo privado%
\csvreader{test.csv}{}%
{\\ \hline \csvcoli & \csvcoliii & \csvcolv}%
\end{tabular}
\end{document}
唯一的区别是后者导入了 spanish babel 包,使用 otherlanguage 环境将语言设置为 english 就可以编译通过,所以问题出在 spanish 和 csvsimple 包之间。
答案1
中的代码在五个地方csvsimple.sty
使用;由于被重新定义,因此这种用法被破坏。\roman
\roman
babel-spanish
您可以向作者提交错误报告,同时自行修复该问题。
\begin{filecontents*}{\jobname.csv}
n,pibreal,pibnom,deflactor,c,isr,trc,tdeflactado,trcdeflactado,I,x,m
2000,1059317580733.46,393302970000,37.127956446,281965700000,10616220000,437870990000,3941585537.81615,162572550457.059,109702668399.757,139614000000,172276800000
\end{filecontents*}
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{csvsimple}
\usepackage{xpatch}
\newcommand{\standardroman}[1]{\romannumeral\value{#1}}
\makeatletter
\xpatchcmd{\csv@breakline@kernel}{\roman}{\standardroman}{}{}
\xpatchcmd{\csv@current@col}{\roman}{\standardroman}{}{}
\xpatchcmd{\set@csv@autohead}{\roman}{\standardroman}{}{}
\xpatchcmd{\set@csv@head}{\roman}{\standardroman}{}{}
\xpatchcmd{\set@csv@nohead}{\roman}{\standardroman}{}{}
\makeatother
\begin{document}
\begin{tabular}{|l|r|r|}%
\bfseries Año & \bfseries PIB & \bfseries Consumo privado%
\csvreader{\jobname.csv}{}%
{\\ \hline \csvcoli & \csvcoliii & \csvcolv}%
\end{tabular}
\end{document}