LaTeXで表をページ外に表示する

LaTeXで表をページ外に表示する

このようなテーブルを作成したいと思います。 ここに画像の説明を入力してください

そのような表のヘッダーを作成する方法がわかりません。これは Latex スクリプトです。

\begin{table*}
\centering
\caption{Some Typical Commands}
\begin{tabular}{|c|c|c|c|c|c|c|c|c|l|} \hline
Product ID&A&Specify Size&Error(\%)&A&Specify Size&Error(\%)&A&Specify Size&Error(\%)\\ \hline
1&Method new&6&11.70&Method+Data&No&3.24&Method+Data&6&10.55\\ \hline
2&A& 1\\ \hline
3&B& 1\\ \hline
4&A& 1\\ \hline
5&B& 1\\ \hline
6&A& 1\\ \hline
7&B& 1\\ \hline
8&A& 1\\ \hline
9&B& 1\\ \hline
10&A& 1\\ \hline\end{tabular}
\end{table*}

スクリプトを実行すると、テーブルの幅がこのようにページからはみ出します。長い単語を次の行に設定し、いくつかの列を結合する方法。 ここに画像の説明を入力してください

答え1

makecellここでは、 を小さいフォント サイズと組み合わせて使用​​するという、少し異なる提案を紹介します。また、 を使用して表の最初の行を追加し\multicolumn、 を使用して最初のセルを垂直方向に中央揃えにしました\multirow。次の例には、垂直線のない 2 番目の表が含まれています。ここでは、パッケージの水平線を使用しbooktabs、 をわずかに減らしました\tabcolsep

\documentclass{article}
\usepackage{geometry}
\usepackage{makecell}
\usepackage{multirow}

\usepackage{booktabs}
\begin{document}

\begin{table*}
\small
\centering
\caption{Some Typical Commands}
\begin{tabular}{|c|c|c|c|c|c|c|c|c|l|} \hline
\multirow{3}{*}{\makecell[cc]{Product \\ ID}} & \multicolumn{3}{c|}{1} & \multicolumn{3}{c|}{2} & \multicolumn{3}{c|}{3}\\ \cline{2-10}
 & A & \makecell[cc]{Specify\\ Size} & \makecell[cc]{Error\\(\%)} & A & \makecell[cc]{Specify\\ Size} & \makecell[cc]{Error\\(\%)}& A & \makecell[cc]{Specify\\ Size} & \makecell[cc]{Error\\(\%)}\\ \hline
1 & \makecell[cc]{Method \\new} & 6&11.70 & \makecell{Method+\\Data} & No & 3.24 & \makecell{Method+\\Data} & 6 & 10.55\\ \hline
2&A& 1 &  &  &  &  &  &  & \\ \hline
3&B& 1 &  &  &  &  &  &  & \\ \hline
4&A& 1 &  &  &  &  &  &  & \\ \hline
5&B& 1 &  &  &  &  &  &  & \\ \hline
6&A& 1 &  &  &  &  &  &  & \\ \hline
7&B& 1 &  &  &  &  &  &  & \\ \hline
8&A& 1 &  &  &  &  &  &  & \\ \hline
9&B& 1 &  &  &  &  &  &  & \\ \hline
10&A& 1 &  &  &  &  &  &  & \\ \hline\end{tabular}
\end{table*}



\begin{table*}
\setlength{\tabcolsep}{5pt}
\centering
\caption{Some Typical Commands}
\begin{tabular}{cccccccccl} \toprule
\multirow{3.25}{*}{\makecell[cc]{Product \\ ID}} & \multicolumn{3}{c}{1} & \multicolumn{3}{c}{2} & \multicolumn{3}{c}{3}\\
\cmidrule(lr){2-4}  \cmidrule(lr){5-7} \cmidrule(lr){8-10}
& A & \makecell[cc]{Specify\\ Size} & \makecell[cc]{Error\\(\%)} & A & \makecell[cc]{Specify\\ Size} & \makecell[cc]{Error\\(\%)}& A & \makecell[cc]{Specify\\ Size} & \makecell[cc]{Error\\(\%)}\\ \midrule
1 & \makecell[cc]{Method \\new} & 6&11.70 & \makecell{Method+\\Data} & No & 3.24 & \makecell{Method+\\Data} & 6 & 10.55\\ 
2&A& 1\\ 
3&B& 1\\ 
4&A& 1\\ 
5&B& 1\\ 
6&A& 1\\ 
7&B& 1\\ 
8&A& 1\\ 
9&B& 1\\ 
10&A& 1\\ \bottomrule
\end{tabular}
\end{table*}

\end{document}

ここに画像の説明を入力してください

答え2

このような表をページに収めるには、 で改行するだけでなくmakecell、 の値\tabcolsep(デフォルトでは 6pt) を減らして、geometryより適切な余白を持つように読み込むこともできます (欄外の注釈を使用しない場合)。 の使用例を追加しました\multicolumn:

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[showframe]{geometry}
\usepackage{caption, makecell}

\begin{document}

\begin{table*}
\centering
\setlength{\tabcolsep}{3pt}
\setlength{\extrarowheight}{2pt}
\renewcommand{\theadfont}{\footnotesize\bfseries}
\caption{Some Typical Commands}
\begin{tabular}{|*9{c|}l|} \hline
\thead{Product\\ ID} & \thead{A} & \thead{Specify\\ Size} & \thead{Error \\ (\%)} & \thead{A } & \thead{Specify \\ Size} & \thead{Error\\(\%)}& \thead{A} & \thead{Specify\\ Size} & \thead{Error\\ (\%)} \\ \hline
1 & \makecell{Method\\\ new} & 6 &11.70 & \makecell{Method\\+Data} & No & 3.24 & \makecell{Method\\ +Data}& 6 & 10.55 \\ \hline
2&A& 1 & & \multicolumn{3}{c|}{} &\multicolumn{3}{c|}{} \\ \hline
3&B& 1 & & & & & & &\\ \hline
4&A& 1 & & & & & & &\\ \hline
5&B& 1 & & & & & & & \\ \hline
6&A& 1 & & & & & & &\\ \hline
7&B& 1 & & & & & & &\\ \hline
8&A& 1 & & & & & & &\\ \hline
9&B& 1 & & & & & & &\\ \hline
10&A& 1 & & & & & & &\\ \hline
\end{tabular}
\end{table*}

\end{document} 

ここに画像の説明を入力してください

関連情報