
複数列の見出しを持つ表をタイプセットしたいのみこれが私の現在の試みです
\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}