LaTeX a tabela fora da página

LaTeX a tabela fora da página

Eu quero criar uma tabela como esta. insira a descrição da imagem aqui

Não sei como criar cabeçalho de tabela assim. Este é o script de látex.

\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*}

Quando executo o script, a largura da tabela sai da página assim. Como definir palavras longas para a próxima linha e mesclar algumas colunas. insira a descrição da imagem aqui

Responder1

Aqui está uma sugestão um pouco diferente usando makecellem combinação com um tamanho de fonte menor. Também adicionei a primeira linha da tabela usando \multicolumne centralizei verticalmente a primeira célula usando \multirow. O exemplo a seguir contém uma segunda tabela sem linhas verticais. Lá eu usei as regras horizontais do booktabspacote e diminuí um pouco o \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}

insira a descrição da imagem aqui

Responder2

Podemos fazer com que essa tabela caiba na página, não apenas usando quebras de linha com makecell, mas também reduzindo o valor de \tabcolsep(6pt por padrão) e carregando geometrypara ter margens mais decentes (se você não usar notas marginais). Eu adicionei uma demonstração do uso de \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} 

insira a descrição da imagem aqui

informação relacionada