我想要一些指导,使我的表格标题看起来像这样:
这是我的代码:
\documentclass{book}
\usepackage{pgfplotstable}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{array}
\usepackage[a4paper,top=4in,bottom=4in,right=1in,left=1in]{geometry}
\usepackage{filecontents}
\begin{filecontents}{good.csv}
Iter dr21 dr31 dr22 dr32
1 0.4900713 0.5051498 0.4907129 0.5064977
2 0.4900256 0.5046520 0.4902557 0.5015202
3 0.4894412 0.5044207 0.4844121 0.4992068
4 0.4893335 0.5046210 0.4833348 0.5012102
5 0.4898289 0.5045439 0.4882890 0.5004394
6 0.4896377 0.5047679 0.4863770 0.5026787
7 0.4897240 0.5049742 0.4872398 0.5047422
8 0.4897114 0.5049562 0.4871140 0.5045621
9 0.4897422 0.5049461 0.4874222 0.5044614
10 0.4897475 0.5048733 0.4874748 0.5037328
\end{filecontents}%
\begin{document}
%%% 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
}
}
}
}
{\scriptsize
\pgfplotstabletypeset[col sep=space,empty header,
columns={Iter,dr21,dr31,dr22,dr32}, % display specified columns
begin table=\bgroup\small\setlength{\tabcolsep}{8pt}\begin{longtable},
end table=\end{longtable}\egroup,
columns/Iter/.style={column type={c},dec sep align,precision=0,fixed,fixed zerofill},
columns/dr21/.style={column type={c},dec sep align,precision=4,fixed,fixed zerofill},
columns/dr31/.style={column type={c},dec sep align,precision=4,fixed,fixed zerofill},
columns/dr22/.style={column type={c},dec sep align,precision=4,fixed,fixed zerofill},
columns/dr32/.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 for Step 4.}%
\label{tab:DataTable}\\\toprule
\multicolumn{2}{c}{$Iter$} &
\multicolumn{2}{m{1.5cm}}{\centering $N(0,0.001^{2})$ $(\delta r_{2})$} &
\multicolumn{2}{m{1.5cm}}{\centering $N(0,0.001^{2})$ $(\delta r_{3})$} &
\multicolumn{2}{m{1.5cm}}{\centering $N(0,0.01^{2})$ $(\delta r_{2})$} &
\multicolumn{2}{m{1.5cm}}{\centering $N(0,0.01^{2})$ $(\delta r_{3})$} \\ \toprule
\endfirsthead
%
\multicolumn{10}{c}%
{{\normalsize\emph{\bfseries{Table \thetable\ Continued from previous page}}}} \\
\toprule
%
\multicolumn{2}{c}{$Iter$} &
\multicolumn{2}{m{1.5cm}}{\centering $N(0,0.001^{2})$ $(\delta r_{2})$} &
\multicolumn{2}{m{1.5cm}}{\centering $N(0,0.001^{2})$ $(\delta r_{3})$} &
\multicolumn{2}{m{1.5cm}}{\centering $N(0,0.01^{2})$ $(\delta r_{2})$} &
\multicolumn{2}{m{1.5cm}}{\centering $N(0,0.01^{2})$ $(\delta r_{3})$} \\ \toprule
\endhead
%
\midrule \multicolumn{10}{r}{{Continued on next page}} \\ \bottomrule
\endfoot
%
\midrule
\multicolumn{10}{r}{{End of Table}} \\ \bottomrule
\endlastfoot
}},
]{good.csv} \label{tabnonoise}
\end{document}
答案1
\documentclass{book}
\usepackage{pgfplotstable}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{array}
\usepackage[a4paper,top=4in,bottom=4in,right=1in,left=1in]{geometry}
\usepackage{filecontents}
\begin{filecontents}{good.csv}
Iter dr21 dr31 dr22 dr32
1 0.4900713 0.5051498 0.4907129 0.5064977
2 0.4900256 0.5046520 0.4902557 0.5015202
3 0.4894412 0.5044207 0.4844121 0.4992068
4 0.4893335 0.5046210 0.4833348 0.5012102
5 0.4898289 0.5045439 0.4882890 0.5004394
6 0.4896377 0.5047679 0.4863770 0.5026787
7 0.4897240 0.5049742 0.4872398 0.5047422
8 0.4897114 0.5049562 0.4871140 0.5045621
9 0.4897422 0.5049461 0.4874222 0.5044614
10 0.4897475 0.5048733 0.4874748 0.5037328
\end{filecontents}%
\usepackage{multirow}
\begin{document}
%%% 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
}
}
}
}
{\scriptsize
\pgfplotstabletypeset[col sep=space,empty header,
columns={Iter,dr21,dr31,dr22,dr32}, % display specified columns
begin table=\bgroup\small\setlength{\tabcolsep}{8pt}\begin{longtable},
end table=\end{longtable}\egroup,
columns/Iter/.style={column type={c},dec sep align,precision=0,fixed,fixed zerofill},
columns/dr21/.style={column type={c},dec sep align,precision=7,fixed,fixed zerofill},
columns/dr31/.style={column type={c},dec sep align,precision=7,fixed,fixed zerofill},
columns/dr22/.style={column type={c},dec sep align,precision=7,fixed,fixed zerofill},
columns/dr32/.style={column type={c},dec sep align,precision=7,fixed,fixed zerofill},
every head row/.append style={before row={%
\caption{Tabulated Data with the Various Parameters for Step 4.}%
\label{tab:DataTable}\\\toprule
\multicolumn{2}{c}{\multirow{2}{*}{$Iter$}} &
\multicolumn{4}{c}{$N(0,0.001^{2})$} & \multicolumn{4}{c}{$N(0,0.001^{2})$}\\\cmidrule(lr){3-6}\cmidrule(lr){7-10}
\multicolumn{2}{c}{}& \multicolumn{2}{c}{$(\delta r_{2})$} & \multicolumn{2}{c}{$(\delta r_{3})$} &
\multicolumn{2}{c}{$(\delta r_{2})$} & \multicolumn{2}{c}{$(\delta r_{3})$} \\ \toprule
\endfirsthead
%
\multicolumn{10}{c}%
{{\normalsize\emph{\bfseries{Table \thetable\ Continued from previous page}}}} \\
\toprule
%
\multicolumn{2}{c}{\multirow{2}{*}{$Iter$}} &
\multicolumn{4}{c}{$N(0,0.001^{2})$} & \multicolumn{4}{c}{$N(0,0.001^{2})$}\\\cmidrule(lr){3-6}\cmidrule(lr){7-10}
\multicolumn{2}{c}{}& \multicolumn{2}{c}{$(\delta r_{2})$} & \multicolumn{2}{c}{$(\delta r_{3})$} &
\multicolumn{2}{c}{$(\delta r_{2})$} & \multicolumn{2}{c}{$(\delta r_{3})$} \\ \toprule
\endhead
%
\midrule \multicolumn{10}{r}{{Continued on next page}} \\ \bottomrule
\endfoot
%
\midrule
\multicolumn{10}{r}{{End of Table}} \\ \bottomrule
\endlastfoot
}},
]{good.csv} \label{tabnonoise}
\end{document}