![如何针对文档的不同部分更改 \pgfplotstableset?](https://linux22.com/image/300939/%E5%A6%82%E4%BD%95%E9%92%88%E5%AF%B9%E6%96%87%E6%A1%A3%E7%9A%84%E4%B8%8D%E5%90%8C%E9%83%A8%E5%88%86%E6%9B%B4%E6%94%B9%20%5Cpgfplotstableset%EF%BC%9F.png)
在 pgfplotstable 包的文档中,您可以在简介中找到以下内容:
键值对可以通过两种方式设置:
- 作为完整文档(或可能是文档的一部分)的默认设置,使用 \pgfplotstableset{⟨options⟩}。例如,文档的前言可能包含 \pgfplotstableset{fixed zerofill,precision=3},以配置句点后的 3 位精度,包括零,以使所有定点数都精确到 3 位。
这或者可能是文档的一部分是我感兴趣的。
我\pgfplotstableset{⟨options⟩}
定义了不同的 via \newcommand
,并打算根据需要在它们之间切换(每个表或多或少)。遗憾的是,我还没有真正让它发挥作用。
- 这可能吗?
- 您能给我指出一个已经完成此操作的示例文档吗?
谢谢!
我将尝试更详细地解释我的问题是什么。
在序言中我创建了多个新命令,例如:
\newcommand{\CCforTABSTable}{\pgfplotstableset{
reset styles,
disable rowcol styles=false,
col sep=&,
header=false,
% precision=2,
% row sep=\\,
columns={0, 5, 8},
columns/0/.style={reset styles,string type,column type={L{.5\linewidth}}, column name={Location}},
columns/5/.style={reset styles,string type,column type={C{.1\linewidth}}, column name={0d}},
columns/8/.style={reset styles,string type,column type={C{.1\linewidth}}, column name={1d}},
begin table=\begin{longtable},
every first row/.append style={ %
before row={\midrule
\endfirsthead
\multicolumn{3}{c}{{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\
\midrule
\endhead
\bottomrule
\endfoot
\bottomrule
\endlastfoot
},
},
end table=\end{longtable},
}
}
和
\newcommand{\IDATableTypeT}{\pgfplotstableset{ %Type T
reset styles,
disable rowcol styles=true,
header=true,
precision=2,
create on use/thiws/.style={create col/expr={(\thisrow{thiws1}+\thisrow{thiws2}+\thisrow{thiws3}+\thisrow{thiws4})/4}},
create on use/thiw/.style={create col/expr={(\thisrow{thiw1}+\thisrow{thiw2}+\thisrow{thiw3}+\thisrow{thiw4})/4}},
%
columns={time, thwaterin, thwaterout, thf, thp, thc, thiws, thiw, tha, thmr, thop},
columns/time/.style={column name={Step}, fixed},
columns/thwaterin/.style={column name={$\tHWaterIn$}, fixed zerofill, precision=1, fixed},
columns/thwaterout/.style={column name={$\tHWaterOut$}, fixed zerofill, precision=1, fixed},
columns/thf/.style={column name={$\tHF$}, fixed zerofill, precision=1, fixed},
columns/thp/.style={column name={$\tHP$}, fixed zerofill, precision=1, fixed},
columns/thc/.style={column name={$\tHC$}, fixed zerofill, precision=1, fixed},
columns/thiws/.style={column name={$\tHIws$}, fixed zerofill, precision=1, fixed},
columns/thiw/.style={column name={$\tHIw$}, fixed zerofill, precision=1, fixed},
columns/tHA/.style={column name={$\tHA$}, fixed zerofill, precision=1, fixed},
columns/thmr/.style={column name={$\tHMr$}, fixed zerofill, precision=1, fixed},
columns/thop/.style={column name={$\tHOp$}, fixed zerofill, precision=1, fixed},
% row sep=\\,
begin table=\begin{longtable},
every first row/.append style={ %
before row={\midrule
\endfirsthead
\multicolumn{10}{c}{{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\
\midrule
\endhead
\bottomrule
\endfoot
\bottomrule
\endlastfoot
},
},
end table=\end{longtable},
}
}
在主文档中我现在首先有:
\CCforTABSTable
\pgfplotstabletypeset[every head row/.append style={before row={%
\caption{Case: bla} %
\label{tab:test}\\ %
\toprule},}
] {\CCData/results/1318AaBb-1day.txt}
以及后者:
\IDATableTypeT % defined in pgfplots.tex
\pgfplotstabletypeset[every head row/.append style={before row={%
\caption{jaja} %
\label{tab:11855-4_HighWallHeatCond_TypeT}\\ %
\toprule},}
] {\IDAData/11855-4_HighWallHeatCond.prn}
到目前为止,我已经遇到了不同的错误,但我不明白的是这个:
PGFPlots: reading {Data/IDA/11855-4_HighWallHeatCond.prn}
./SimplyTabs/Appendix/ValidationIDA.tex:14: Package pgfplots Error: Sorry,
could not retrieve column 'time' from table 'Data/IDA/11855-4_HighWallHeatCond.prn'.
Please check spelling (or introduce name aliases)..
然而文件内容如下:
time order qhc qhcirc qhcontot qhf qhiws1 qhiws2 qhiws3 qhiws4 qhradtot tha thc thf thiw1 thiw2 thiw3 thiw4 thiws1 thiws2 thiws3 thiws4 thmr thmrandt_1 thmrandt_2 thop thp thwaterin thwaterout
4679.000000 1.0000 209.93 -880.68 30.000 32.953 -20.663 -17.220 -20.663 -17.220 10.000 23.330 21.846 22.378 22.902 22.902 22.902 22.902 22.900 22.900 22.900 22.900 22.481 23.330 -7.1583 22.763 21.232 20.000 20.707
4680.000000 1.0000 125.03 -799.28 30.000 5.0923 -20.864 -17.386 -20.864 -17.386 10.000 22.306 21.584 22.096 22.397 22.397 22.397 22.397 22.395 22.395 22.395 22.395 22.105 22.306 -7.1583 22.202 21.110 20.000 20.637
答案1
如果你没有找到重置样式键,我建议你定义要应用的样式全部表格,例如:
\pgfplotstableset{zerofill}
并为您想要控制的各种事物准备不同的样式:
\pgfplotstableset{My Style1/.append style={precision=3}}
\pgfplotstableset{My Style2/.append style={precision=1}}
代码:
\documentclass{article}
\usepackage{pgfplotstable}
\pgfplotsset{compat=newest}
%% Setting for ENTIRE document
\pgfplotstableset{zerofill}
%% Settings that you selectively want to control
\pgfplotstableset{My Style1/.append style={precision=3}}
\pgfplotstableset{My Style2/.append style={precision=1}}
%\usepackage{filecontents}% <--- Commented out so as to now overwrite sample.csv
\begin{filecontents*}{sample.csv}
Column A, Column B, Column C
99, 98, 96
88, 87, 84
\end{filecontents*}
\pgfplotstableread[col sep=comma]{sample.csv}\MySampleData
\begin{document}
\pgfplotstabletypeset[My Style1]\MySampleData
\bigskip\par
\pgfplotstabletypeset[My Style2]\MySampleData
\end{document}