大家好!我将表格存储在 CSV 文件中,并使用 pgfplotstable 包调用这些文件。这很好用,但我遇到了一个挑战。我需要将括号中的单位(即 (MeV) 和 (mb/MeV/sr) 等)移到下一行,这样我就会有两行专门用于头行,并且列的宽度不会太大。我需要有人来帮我!请在下面找到我的 latex 代码摘录。提前致谢...
\begin{table}
\caption{\label{tab:knockho3}As in table~\ref{tab:knockho1} but for complementary angles of \mbox{$60^\circ - 120^\circ$}.}
\centering
\resizebox{\columnwidth}{!}{%
\pgfplotstabletypeset[col sep=comma,
columns/Energy (MeV)/.style={string type},
columns/Experiment (mb/MeV/sr)/.style={string type},
columns/Error (mb/MeV/sr)/.style={string type},
columns/Simulation (mb/MeV/sr)/.style={string type},
every head row/.style={
before row=\toprule,
after row=\midrule},
every last row/.style={after row=\bottomrule}
]{Tables/knockho3.csv}%
}
\end{table}
答案1
解答未解答的问题....
您可以通过各种框强制在标题单元格中换行,或者只使用专门用于单位的另一行。这是一个包含虚构数据和单位的简单示例(希望我得到的是正确的)。
\documentclass{article}
\usepackage{pgfplotstable,booktabs,siunitx,array}
\sisetup{per-mode=symbol}
\pgfplotsset{compat=1.13}
\begin{document}
\begin{table}
\caption{Complementary angles of $60^\circ - 120^\circ$.}
\centering
\pgfplotstabletypeset[%col sep=comma,
header=false,
columns={[index]0,[index]1,[index]2,[index]3},
every col no 0/.style={column name=Energy},
every col no 1/.style={column name=Experiment},
every col no 2/.style={column name=Error},
every col no 3/.style={column name=Simulation},
every head row/.append style={
before row=\toprule,
after row/.add={}{%
\arraybackslash%
[\si{\mega\electronvolt}]%
& {[\si{\milli\barn\per\mega\electronvolt\per\steradian}]}%
& {[\si{\milli\barn\per\mega\electronvolt\per\steradian}]}%
& {[\si{\milli\barn\per\mega\electronvolt\per\steradian}]}\\ \midrule
}
},
every last row/.style={after row=\bottomrule}
]{
1 2 3 4
5 6 7 8
9 10 11 12
}%
\end{table}
\end{document}