
我想排版一個帶有多列標題的表格僅有的。這是我目前的嘗試
\documentclass{article}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\usepackage{array}
\usepackage{colortbl}
\begin{document}
\pgfplotstabletypeset[col sep=&, header=false,
every head row/.style={
before row={%
\toprule
Facteurs & \multicolumn{5}{c}{Niveaux}\\
}},
every last row/.style={
after row=\bottomrule},
display columns/0/.style={string type}
]
{%
\pgfutilensuremath{\chi} & 8 & 11 & 14 & &
5 & 8 & 11 & 14 & 45 & 2.456
q & 8 & 11 & 14 & & 3
x & 8 & 11 & 14 & 5612345 & 4
b & 8 & 11 & 14 & & 5
}
\end{document}
給出以下結果:
如何去除圖中紅色圈起來的標題行?
答案1
從 PGFPlots 1.6 版本開始(我認為),一個新的金鑰output empty row
已經可用,可以抑制行的列印。這可以按照您的風格使用:
\documentclass{article}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\begin{document}
\pgfplotstabletypeset[
col sep=&, header=false,
every head row/.style={
output empty row,
before row={%
\toprule
Facteurs & \multicolumn{5}{c}{Niveaux}\\
}
},
every last row/.style={
after row=\bottomrule
},
display columns/0/.style={string type}
]
{%
\pgfutilensuremath{\chi} & 8 & 11 & 14 & &
5 & 8 & 11 & 14 & 45 & 2.456
q & 8 & 11 & 14 & & 3
x & 8 & 11 & 14 & 5612345 & 4
b & 8 & 11 & 14 & & 5
}
\end{document}
如果您使用的是早期版本並且無法/不想更新,這裡有一個稍微粗暴的解決方法。您可以新增程式碼
\makeatletter
\pgfplotsset{
/pgfplots/table/omit header/.style={%
/pgfplots/table/typeset cell/.append code={%
\ifnum\c@pgfplotstable@rowindex=-1
\pgfkeyslet{/pgfplots/table/@cell content}\pgfutil@empty%
\fi
}
}
}
\makeatother
在你的序言中,這使得一種風格omit header row
可用。如果您在 中使用該鍵\pgfplotstable
,則每個表格儲存格的輸出例程將透過檢查我們是否位於行號-1
(標題行)中進行修改,如果是,則不會產生任何輸出。
\documentclass{article}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\makeatletter
\pgfplotsset{
/pgfplots/table/omit header/.style={%
/pgfplots/table/typeset cell/.append code={%
\ifnum\c@pgfplotstable@rowindex=-1
\pgfkeyslet{/pgfplots/table/@cell content}\pgfutil@empty%
\fi
}
}
}
\makeatother
\begin{document}
\pgfplotstabletypeset[
col sep=&,
header=false,
every head row/.style={
before row={%
\toprule
Facteurs & \multicolumn{5}{c}{Niveaux}\\
}
},
every last row/.style={
after row=\bottomrule
},
display columns/0/.style={string type},
omit header
]
{%
\pgfutilensuremath{\chi} & 8 & 11 & 14 & &
5 & 8 & 11 & 14 & 45 & 2.456
q & 8 & 11 & 14 & & 3
x & 8 & 11 & 14 & 5612345 & 4
b & 8 & 11 & 14 & & 5
}
\end{document}