
下の画像のような表を作成したいと思います。
\documentclass{article}
\begin{document}
\begin{table*}
\begin{tabular}{|l|l|l|l|l|l|l|} \hline
&\multicolumn{3}{c|}{A} &\multicolumn{3}{c|}{B} \\ \cline{2-7}
1 & a & b & c & d & e & f \\ \hline
2 & g & h & i & j & k & l \\ \hline
\end{tabular}
\end{table*}
\end{document}
しかし、次のように、空の行全体を含むテーブルを取得することはできません。コールドキャッシュ中央に と書かれています。何か方法はあるのでしょうか?
表の下にキャプションも欲しいです。
答え1
次のコードでは、あなたが求めている表を再現する 2 つの方法を示しています。最初の表は、あなたが要求したものを作成することを目的としています。 で正しい方向に進んでいます。投稿した画像ではほとんどのセルが右揃えになっているように見えるため、ではなく\multicolumn
デフォルトのセル配置を設定したことに注意してください。左揃えになっているセルについては (r
l
つまり、最初の列にあるものなど)、\multicolumn{1}{l}{...}
これらの特定のセルの配置を変更するコマンドを使用しました。
最後に、あなたが要求したような方法でテーブルを作成することは強くお勧めしません。特に、booktabs
ドキュメンテーション(特にセクション 2) では、表の組版に関する適切な印刷方法についての推奨事項がいくつか示されています。
\documentclass{article}
\usepackage{booktabs} % used for prettier tables
\usepackage[justification=centering]{caption} % needed to center caption
\begin{document}
Table~\ref{fig:replication-as-requested} replicates the image as you've requested, but Table~\ref{fig:replication-as-recommended} replicates the image as I would recommend, based on considerations from the \verb|booktabs| documentation.
\begin{table}[htbp]
\centering
\caption{LUBM 1 Billion (time in seconds)}\label{fig:replication-as-requested}
\begin{tabular}{|r|r|r|r|r|r|r|r|}
\hline
& Q1 & Q2 & Q3 & Q4 & Q5 & Q6 & Geom.~Mean \\ \hline
\multicolumn{8}{|c|}{Cold caches} \\ \hline
\multicolumn{1}{|l|}{RDF-3X} & a & b & c & d & e & f & g \\ \hline
\multicolumn{1}{|l|}{MonetDB} & a & b & c & d & e & f & g \\ \hline
\multicolumn{1}{|l|}{TripleBit} & a & b & c & d & e & f & g \\ \hline
\multicolumn{8}{|c|}{Warm caches} \\ \hline
\multicolumn{1}{|l|}{RDF-3X} & a & b & c & d & e & f & g \\ \hline
\multicolumn{1}{|l|}{MonetDB} & a & b & c & d & e & f & g \\ \hline
\multicolumn{1}{|l|}{TripleBit} & a & b & c & d & e & f & g \\ \hline
\end{tabular}
\end{table}
\begin{table}[htbp]
\centering
\caption{LUBM 1 Billion (time in seconds)}\label{fig:replication-as-recommended}
\begin{tabular}{rrrrrrrr}
\toprule
& Q1 & Q2 & Q3 & Q4 & Q5 & Q6 & Geom.~Mean \\ \midrule
\multicolumn{8}{c}{Cold caches} \\ \midrule
\multicolumn{1}{l}{RDF-3X} & a & b & c & d & e & f & g \\
\multicolumn{1}{l}{MonetDB} & a & b & c & d & e & f & g \\
\multicolumn{1}{l}{TripleBit} & a & b & c & d & e & f & g \\ \midrule
\multicolumn{8}{c}{Warm caches} \\ \midrule
\multicolumn{1}{l}{RDF-3X} & a & b & c & d & e & f & g \\
\multicolumn{1}{l}{MonetDB} & a & b & c & d & e & f & g \\
\multicolumn{1}{l}{TripleBit} & a & b & c & d & e & f & g \\ \bottomrule
\end{tabular}
\end{table}
\end{document}
答え2
私はあなたの(動作しない例)を、Johannes_B の提案コメントを考慮して追加した MWE に拡張します。テーブルの設計については、私は彼に同意します。考えられる MWE は次のとおりです。
\documentclass{article}
\begin{document}
\begin{table}\centering
\begin{tabular}{*{7}{|l}|}
\hline
& \multicolumn{3}{c|}{A}
&\multicolumn{3}{c|}{B} \\
\hline
1 & a & b & c & d & e & f \\
\hline
\multicolumn{7}{|c|}{cold cashes} \\
\hline
2 & g & h & i & j & k & l \\
\hline
\end{tabular}
\caption{My very important table}
\end{table}
\end{document}
上記の例がお役に立てば幸いです。
答え3
もう一つの試みですが、あなたが示したイメージに近いです。
\documentclass[]{article}
\usepackage[papersize={18cm,8cm}]{geometry} % change this line in actual case.
\usepackage{multirow}
\begin{document}
\begin{table}\centering
\begin{tabular}{*{8}{|c}|}
\hline
& Q1 & Q2 & Q3 & Q4 & Q5 & Q6 & \multirow{2}{*}{Geom. Mean}\\ \cline{1-7}
\#Results &10 &10&0&8&2528&4.39997& \\ \hline
\multicolumn{8}{|c|}{Cold cashes} \\ \hline
RDF-3X & &&&&&& \\ \hline
MonetDB & &&&&&& \\ \hline
TripleBit & &&&&&& \\ \hline
\multicolumn{8}{|c|}{Warm cashes} \\ \hline
RDF-3X & &&&&&& \\ \hline
MonetDB & &&&&&& \\ \hline
TripleBit & 0.0002 &0.0002&7.5977&0.0009&27.2772&36.5613& 0.0805 \\ \hline
\end{tabular}
\caption{LUBMI 1 Billion (time in seconds)}
\end{table}
\end{document}