由于某种原因,我无法编译我的 pgfplot 表。你能告诉我我做错了什么吗?谢谢。
这是我的代码。
\documentclass{book}
\usepackage{pgfplotstable}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{array}
\usepackage[a4paper,top=4in,bottom=4in,right=1in,left=1in]{geometry}
\usepackage{filecontents}
%%% Code from Dr. Christian ------ for not using headers.----------------------
\pgfkeysifdefined{/pgfplots/table/output empty row/.@cmd}{
% upcoming releases offer this more convenient option:
\pgfplotstableset{
empty header/.style={
every head row/.style={output empty row},
}
}
}{
% versions up to and including 1.5.1 need this:
\pgfplotstableset{
empty header/.style={
typeset cell/.append code={%
\ifnum\pgfplotstablerow=-1 %
\pgfkeyssetvalue{/pgfplots/table/@cell content}{}%
\fi
}
}
}
}
\begin{filecontents}{data133.dat}
iter theta1 r2v r3v x y
1 49.68590 1.08195 0.09195 1.40000 1.65000
2 49.85442 1.08549 0.09549 1.39970 1.65951
3 50.03335 1.08882 0.09882 1.39879 1.66899
4 50.22198 1.09195 0.10195 1.39729 1.67839
5 50.41959 1.09485 0.10485 1.39519 1.68767
6 50.62543 1.09752 0.10752 1.39251 1.69681
7 50.83875 1.09996 0.10996 1.38926 1.70575
8 51.05880 1.10214 0.11214 1.38544 1.71447
9 51.28480 1.10407 0.11407 1.38108 1.72293
\end{filecontents}%
\begin{document}
\pgfplotstabletypeset[col sep=space,empty header,
columns={iter,theta1,r2v,r3v,x,y}, % display specified columns
begin table=\bgroup\small\setlength{\tabcolsep}{3pt}\begin{longtable},
end table=\end{longtable}\egroup,
columns/Iter/.style={column type={c},dec sep align,precision=0,fixed,fixed zerofill},
columns/theta1/.style={column type={c},dec sep align,precision=4,fixed,fixed zerofill},
columns/r2v/.style={column type={c},dec sep align,precision=4,fixed,fixed zerofill},
columns/r3v/.style={column type={c},dec sep align,precision=4,fixed,fixed zerofill},
columns/x/.style={column type={c},dec sep align,precision=4,fixed,fixed zerofill},
columns/y/.style={column type={c},dec sep align,precision=4,fixed,fixed zerofill},
every head row/.append style={before row={%
\caption{Tabulated Data with the Various Parameters.}%
\label{tabnonoise}\\\toprule
\multicolumn{2}{c}{$Iter$} &
\multicolumn{2}{c}{$\theta_{1}$} &
\multicolumn{2}{c}{$r_{2v}$} &
\multicolumn{2}{c}{$r_{3v}$} &
\multicolumn{2}{c}{$x$} &
\multicolumn{2}{c}{$y$}\\ \toprule
\endfirsthead
%
\multicolumn{12}{r}%
{{\normalsize\emph{\bfseries\textcolor{mybluei}{Table \thetable\ Continued from previous page}}}} \\
\toprule
%
\multicolumn{2}{c}{$Iter$} &
\multicolumn{2}{c}{$\theta_{1}$} &
\multicolumn{2}{c}{$r_{2v}$} &
\multicolumn{2}{c}{$r_{3v}$} &
\multicolumn{2}{c}{$x$} &
\multicolumn{2}{c}{$y$}\\ \toprule
\endhead
%
\midrule \multicolumn{12}{r}{{Continued on next page}} \\ \bottomrule
\endfoot
%
\midrule
\multicolumn{12}{r}{{End of Table}} \\ \bottomrule
\endlastfoot
}},%
%outfile=pgfplotstable.example1.out.tex
%
]{data133.dat}
\end{document}
答案1
您没有定义使用的蓝色,并且在标题中指定了 12 列而不是 11 列(第一个整数列没有翻倍)
\documentclass{book}
\usepackage{pgfplotstable}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{array}
\usepackage[a4paper,top=4in,bottom=4in,right=1in,left=1in]{geometry}
\definecolor{mybluei}{rgb}{0,0,1}
\usepackage{filecontents}
%%% Code from Dr. Christian ------ for not using headers.----------------------
\pgfkeysifdefined{/pgfplots/table/output empty row/.@cmd}{
% upcoming releases offer this more convenient option:
\pgfplotstableset{
empty header/.style={
every head row/.style={output empty row},
}
}
}{
% versions up to and including 1.5.1 need this:
\pgfplotstableset{
empty header/.style={
typeset cell/.append code={%
\ifnum\pgfplotstablerow=-1 %
\pgfkeyssetvalue{/pgfplots/table/@cell content}{}%
\fi
}
}
}
}
\begin{filecontents}{data133.dat}
iter theta1 r2v r3v x y
1 49.68590 1.08195 0.09195 1.40000 1.65000
2 49.85442 1.08549 0.09549 1.39970 1.65951
3 50.03335 1.08882 0.09882 1.39879 1.66899
4 50.22198 1.09195 0.10195 1.39729 1.67839
5 50.41959 1.09485 0.10485 1.39519 1.68767
6 50.62543 1.09752 0.10752 1.39251 1.69681
7 50.83875 1.09996 0.10996 1.38926 1.70575
8 51.05880 1.10214 0.11214 1.38544 1.71447
9 51.28480 1.10407 0.11407 1.38108 1.72293
\end{filecontents}%
\begin{document}
\pgfplotstabletypeset[col sep=space,empty header,
columns={iter,theta1,r2v,r3v,x,y}, % display specified columns
begin table=\bgroup\small\setlength{\tabcolsep}{3pt}\begin{longtable},
end table=\end{longtable}\egroup,
columns/Iter/.style={column type={c},dec sep align,precision=0,fixed,fixed zerofill},
columns/theta1/.style={column type={c},dec sep align,precision=4,fixed,fixed zerofill},
columns/r2v/.style={column type={c},dec sep align,precision=4,fixed,fixed zerofill},
columns/r3v/.style={column type={c},dec sep align,precision=4,fixed,fixed zerofill},
columns/x/.style={column type={c},dec sep align,precision=4,fixed,fixed zerofill},
columns/y/.style={column type={c},dec sep align,precision=4,fixed,fixed zerofill},
every head row/.append style={before row={%
\caption{Tabulated Data with the Various Parameters.}%
\label{tabnonoise}\\\toprule
\multicolumn{1}{c}{$Iter$} &
\multicolumn{2}{c}{$\theta_{1}$} &
\multicolumn{2}{c}{$r_{2v}$} &
\multicolumn{2}{c}{$r_{3v}$} &
\multicolumn{2}{c}{$x$} &
\multicolumn{2}{c}{$y$}\\ \toprule
\endfirsthead
%
\multicolumn{11}{r}%
{{\normalsize\emph{\bfseries\textcolor{mybluei}{Table \thetable\ Continued from previous page}}}} \\
\toprule
%
\multicolumn{1}{c}{$Iter$} &
\multicolumn{2}{c}{$\theta_{2}$} &
\multicolumn{2}{c}{$r_{2v}$} &
\multicolumn{2}{c}{$r_{3v}$} &
\multicolumn{2}{c}{$x$} &
\multicolumn{2}{c}{$y$}\\ \toprule
\endhead
%
\midrule \multicolumn{11}{r}{{Continued on next page}} \\ \bottomrule
\endfoot
%
\midrule
\multicolumn{11}{r}{{End of Table}} \\ \bottomrule
\endlastfoot
}},%
%outfile=pgfplotstable.example1.out.tex
%
]{data133.dat}
\end{document}