我必须向德国发送大量税务文件。我创建了一些 TeX 文件,这些文件使用一些 CSV 文件自动生成此报告。到目前为止,我还是一名学生,数字很低。去年我开始工作,我刚刚注意到我去年的收入导致csvsimple
失败。我该如何解决?
最小示例
2017-nicht-selbststaendig.csv
:
Datum;Text;Betrag
18.12.2017;Lohnsteuer Empoyer 2017;16384.00
main.tex
:
\documentclass[a4paper, 12pt]{article}
\usepackage[utf8]{inputenc} % this is needed for umlauts
\usepackage[ngerman]{babel} % this is needed for umlauts
\usepackage[T1]{fontenc} % needed for right umlaut output in pdf
\usepackage[ngerman, num]{isodate} % get DD.MM.YYYY dates
\usepackage[locale=DE,group-minimum-digits={3}]{siunitx}
\usepackage{parskip}
\usepackage{fancyhdr}
\usepackage[rmargin=2.4cm]{geometry}
\usepackage{csvsimple}
\usepackage{pgfplots}
\fancypagestyle{appendix}{%
\fancyhead{}
\renewcommand{\headrulewidth}{0pt}
}
\setlength{\headheight}{15pt} % fixes \headheight warning
\lhead{Martin Thoma, Poststraße 1, 81234 München}
\rhead{Id-Nr. 72 123 123}
% Begin document %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\pagestyle{fancy}
\section*{Überschussrechnung 2017}
\subsection*{Einnahmen aus nicht-selbstständiger Tätigkeit}
\csvreader[before reading=\def\nichstselbststaendig{0},separator=semicolon]{2017-nicht-selbststaendig.csv}{Betrag=\Betrag}{%
\pgfmathsetmacro{\nichstselbststaendig}{\nichstselbststaendig+\Betrag}%
}
\begin{tabular}{|p{2cm}|p{10.4cm}|p{2cm}|}\hline%
\textbf{Datum} & \textbf{Text} & \textbf{Betrag}
\csvreader[head to column names,separator=semicolon]{2017-nicht-selbststaendig.csv}{}%
{\\\hline\Datum & \Text &\hfill\num[round-mode=places,round-precision=2]{\Betrag}}%
\\\hline\hline
\multicolumn{2}{|l|}{Summe} & \hfill\num[round-mode=places,round-precision=2]{\nichstselbststaendig}
\\\hline
\end{tabular}
\end{document}
错误
! Dimension too large.
<to be read again>
\relax
l.30 }
答案1
问题不是 csvsimple,而是 pgfmath。如果你使用 xfp 并\fpeval
进行求和,它会起作用:
\documentclass[a4paper, 12pt]{article}
\usepackage[utf8]{inputenc} % this is needed for umlauts
\usepackage[ngerman]{babel} % this is needed for umlauts
\usepackage[T1]{fontenc} % needed for right umlaut output in pdf
\usepackage[ngerman, num]{isodate} % get DD.MM.YYYY dates
\usepackage[locale=DE,group-minimum-digits={3}]{siunitx}
\usepackage{parskip}
\usepackage{fancyhdr}
\usepackage[rmargin=2.4cm]{geometry}
\usepackage{csvsimple,xfp}
\fancypagestyle{appendix}{%
\fancyhead{}
\renewcommand{\headrulewidth}{0pt}
}
\setlength{\headheight}{15pt} % fixes \headheight warning
\lhead{Martin Thoma, Poststraße 1, 81234 München}
\rhead{Id-Nr. 72 123 123}
% Begin document %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\pagestyle{fancy}
\section*{Überschussrechnung 2017}
\subsection*{Einnahmen aus nicht-selbstständiger Tätigkeit}
\csvreader[before reading=\def\nichstselbststaendig{0},separator=semicolon]{testcsv.csv}{Betrag=\Betrag}{%
\edef\nichstselbststaendig{\fpeval{\nichstselbststaendig+\Betrag}}%
}
\begin{tabular}{|p{2cm}|p{10.4cm}|p{2cm}|}\hline%
\textbf{Datum} & \textbf{Text} & \textbf{Betrag}
\csvreader[head to column names,separator=semicolon]{testcsv.csv}{}%
{\\\hline\Datum & \Text &\hfill\num[round-mode=places,round-precision=2]{\Betrag}}%
\\\hline\hline
\multicolumn{2}{|l|}{Summe} & \hfill\num[round-mode=places,round-precision=2]{\nichstselbststaendig}
\\\hline
\end{tabular}
\end{document}