我正在使用直接的\pgfplotstabletypeset
.
因為我想在其中一個單元格中插入手動中斷以減小該單元格的寬度,所以我\pbox
按照中的建議添加了https://tex.stackexchange.com/a/11555
問題是最終的高度對於我的口味來說有點太小了:
正如您所看到的,“some”位於單元格的最頂部,而“text”位於單元格的最底部。我想在頂部和底部有一個小的額外空間。
我無法用我嘗試過的東西來實現這一點。
有任何想法嗎?
這是顯示問題的最小工作範例:
\documentclass[11pt,a4paper]{article}
\usepackage{booktabs}
\usepackage{colortbl}
\usepackage{pgfplotstable}
\pgfplotstableset{
column type=l,
every head row/.style={
before row=\toprule,
after row=\midrule},
every even row/.style={before row={\rowcolor[gray]{0.85}}},
every odd row/.style={before row={\rowcolor[gray]{0.95}}},
every last row/.style={
after row=\bottomrule},
col sep = &,
row sep=\\,
string type,
}
\usepackage{pbox}
\begin{document}
\begin{table}[h]
\pgfplotstabletypeset{
a & b \\
1 & 2 \\
\pbox[c]{20cm}{some \\ long \\ text} & foo \\
3 & 4 \\
}
\end{table}
\end{document}
伯納德,感謝您在下面發布的建議。
然而,當表中存在較長的行時,就會出現問題。
請將以下行新增至您發布的最小工作範例:
\makecell{some even longer \\ text that spans \\ three lines} & foo \\
這將產生下表:
你說不用 pgfplotstable 也可以得到相同的結果表。這對我來說沒問題——如果您有建議如何以不同的方式做,我也願意使用。
Paul Gaborit 請注意:我以匿名用戶的身份發布了最初的問題,因此當我返回此頁面時,我無法評論自己的評論或任何其他評論,或者?
答案1
您可以使用該makecell
包,而不是\pbox
:該包允許使用其\makecell
、\thead
和命令在表格單元\rotcell
格中換行\rothead
:
\documentclass[11pt,a4paper]{article}
\usepackage{booktabs}
\usepackage{colortbl}
\usepackage{pgfplotstable}
\pgfplotstableset{
column type=l,
every head row/.style={
before row=\toprule,
after row=\midrule},
every even row/.style={before row={\rowcolor[gray]{0.85}}},
every odd row/.style={before row={\rowcolor[gray]{0.95}}},
every last row/.style={
after row=\bottomrule},
col sep = &,
row sep=\\,
string type,
}
\usepackage{makecell}
\renewcommand\cellalign{lc}
\begin{document}
\begin{table}[h]
\pgfplotstabletypeset{
a & b \\
1 & 2 \\
\makecell{some \\ long \\ text} & foo \\
3 & 4 \\
}
\end{table}
\end{document}
註:您可以在不使用 的情況下獲得相同的結果表pgfplotstable
。