当我在 LaTeX 进程中创建表格时,我能够访问这些项目,例如在循环中。如果我使用“\pgfplotstableread”从文件中读取表格,则它会拒绝读取索引大于 6 且尾随 0 的值。它给出以下消息:
! Package PGF Math Error: Digit `8' invalid for base 8 (in '08').
但是我怎样才能读取以零开头的值,或者,我怎样才能将基数更改为 10?代码:
\documentclass[ngerman]{article}
\usepackage{tikz}
\usepackage{amsmath}
\usepackage{csvsimple}
\usepackage{pgfplots}
\usepackage{filecontents}
\usetikzlibrary{calendar,calc}
\usepackage{pgfplotstable}
\begin{document}
\pgfplotstableset{
create on use/One/.style={create col/set list={01,02,03,04,05,06,07,08,09,10}},
create on use/Two/.style={create col/set list={11,45,63,7,30,63,18,22,78,10}}
}
\pgfplotstablenew[columns={One, Two}]{10}\NewTableT
% Reading the table
\pgfplotstablegetelem{0}{One}\of\NewTableT
\pgfplotstablegetelem{1}{Two}\of\NewTableT
%Running:
\foreach \x in {0,1,...,9}{
\pgfplotstablegetelem{1}{One}\of{\NewTableT}
\pgfmathtruncatemacro{\Monat}{\pgfplotsretval}
\pgfplotstablegetelem{\x}{Two}\of{\NewTableT}
\pgfmathtruncatemacro{\Tag}{\pgfplotsretval}
{\x} Day: {\Tag} and Month: {\Monat}\\
}
\line(1,0){200}
% data in table zeitentabelle.dat:
%% Monat Tag Anfang Ende
%% 01 01 0 0
%% 01 02 0 0
%% 01 03 0 0
%% 01 04 0 0
%% 01 05 0 0
%% 01 06 0 0
%% 01 07 7 16
%% 01 08 7 17
%% 01 09 6 17
%% 01 10 0 0
%% 01 11 0 0
% Reading the table
\pgfplotstableread{zeitentabelle.dat}\NewTable
\pgfplotstablegetelem{0}{Monat}\of\NewTable
\pgfplotstablegetelem{1}{Tag}\of\NewTable
\pgfplotstablegetelem{2}{Anfang}\of\NewTable
\pgfplotstablegetelem{3}{Ende}\of\NewTable
%Not Running for numbers bigger than "08":
\foreach \x in {0,1,...,10}{
\pgfplotstablegetelem{1}{Monat}\of{\NewTable}
\pgfmathtruncatemacro{\Monat}{\pgfplotsretval}
\pgfplotstablegetelem{\x}{Tag}\of{\NewTable}
\pgfmathtruncatemacro{\Tag}{\pgfplotsretval}
{\x} Day: {\Tag} and Month: {\Monat}\\
}
\end{document}
错误信息如下:
! Package PGF Math Error: Digit `8' invalid for base 8 (in '08').