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. 다음 예에는 수직선이 없는 두 번째 테이블이 포함되어 있습니다. 거기서 나는 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} 

여기에 이미지 설명을 입력하세요

관련 정보