
설정
아래 MWE를 사용하여 "제목 1"을 4개의 하위 제목으로 중앙에 배치하고 "제목 2"와 "제목 3"을 각각 하위 제목으로 중앙에 배치하려고 합니다.
MWE
\documentclass[12pt, oneside]{book}
%MARGIN SETTINGS
\usepackage{geometry}
\geometry{
paper=a4paper,
inner=2.5cm,
outer=2.5cm,
bindingoffset=0.0cm,
top=2.5cm,
bottom=2.5cm,
headsep=4.5mm,
footskip=7.4mm,
%showframe
}
%FOR TABLES
\usepackage{float}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{siunitx}
\newcolumntype{?}{!{\vrule width 1pt}}
%----------------------BEGIN-------------------------
\begin{document}
\begin{table}[H]
\centering
\resizebox{\textwidth}{!}{%
\begin{tabular}{l|l ? S|S|S|S ? S|S ? S|S} %S centres
%\begin{tabular}{l|l ? S|S|S|S | S|S | S|S}
\toprule
\multirow{2}{*}{Column 1} &
\multirow{2}{*}{Column 2} & %& &
\multicolumn{2}{c}{Heading 1} & %&
\multicolumn{2}{c}{Heading 2} &
\multicolumn{2}{c}{Heading 3} \\
& & {Sub 1} & {Sub 2} & {Sub 3} & {Sub 4} & {Sub 1} & {Sub 2} & {Sub 1} & {Sub 2} \\
\midrule
A1 = item1 & 0.0001 & 1 & 1 & 1 & 2 & 3 & 4 & 5 & 6 \\
%\hline
A2 = item2 & 0.0002 & 1 & 1 & 7 & 8 & 9 & 10 & 11 & 12 \\
%\hline
A3 = item3 & 0.0003 & 1 & 1 & 13 & 14 & 15 & 16 & 17 & 18 \\
\bottomrule
\end{tabular}}
\caption{Test Table} \label{tbl:BPF}
\end{table}
\end{document}
문제
more 를 사용하여 &
제목을 정렬하면 다음 오류가 발생합니다. 수직선이 위쪽으로 넘쳤습니다.
목표
위와 같이 제목을 중앙에 배치하지만 "Sub 1 Sub 2"와 "Sub 4 Sub 1" 사이에 수직선이 넘치지 않게 하는 방법
답변1
당신이 원하는 것이 무엇인지 잘 모르겠습니다. 이런 뜻인가요? 그렇다면: 올바른 열 수를 지정해야 합니다 \multicolumn
("제목 1"의 경우 4). 수직 규칙을 가지려면 의 열 유형 사양에 추가하면 됩니다 \multicolumn
.
\documentclass[12pt, oneside]{book}
%MARGIN SETTINGS
\usepackage{geometry}
\geometry{
paper=a4paper,
inner=2.5cm,
outer=2.5cm,
bindingoffset=0.0cm,
top=2.5cm,
bottom=2.5cm,
headsep=4.5mm,
footskip=7.4mm,
%showframe
}
%FOR TABLES
\usepackage{float}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{siunitx}
\newcolumntype{?}{!{\vrule width 1pt}}
%----------------------BEGIN-------------------------
\begin{document}
\begin{table}[H]
\centering
\resizebox{\textwidth}{!}{%
\begin{tabular}{l|l ? S|S|S|S ? S|S ? S|S} %S centres
%\begin{tabular}{l|l ? S|S|S|S | S|S | S|S}
\toprule
\multirow{2}{*}{Column 1} &
\multirow{2}{*}{Column 2} & %& &
\multicolumn{4}{c?}{Heading 1} & %&
\multicolumn{2}{c?}{Heading 2} &
\multicolumn{2}{c}{Heading 3} \\
& & {Sub 1} & {Sub 2} & {Sub 3} & {Sub 4} & {Sub 1} & {Sub 2} & {Sub 1} & {Sub 2} \\
\midrule
A1 = item1 & 0.0001 & 1 & 1 & 1 & 2 & 3 & 4 & 5 & 6 \\
%\hline
A2 = item2 & 0.0002 & 1 & 1 & 7 & 8 & 9 & 10 & 11 & 12 \\
%\hline
A3 = item3 & 0.0003 & 1 & 1 & 13 & 14 & 15 & 16 & 17 & 18 \\
\bottomrule
\end{tabular}}
\caption{Test Table} \label{tbl:BPF}
\end{table}
\end{document}
일반적으로 테이블 크기를 조정하는 것은 나쁜 습관으로 간주됩니다. 대신 \small
텍스트 너비에 맞게 만드는 데 사용할 수 있습니다 . 또한 테이블은 수직선이 적을수록('아니요'라고 읽음) 더 보기 좋아지는 경향이 있습니다. 다음을 사용하는 것을 고려할 수 있습니다.
\documentclass[12pt, oneside]{book}
%MARGIN SETTINGS
\usepackage{geometry}
\geometry{
paper=a4paper,
inner=2.5cm,
outer=2.5cm,
bindingoffset=0.0cm,
top=2.5cm,
bottom=2.5cm,
headsep=4.5mm,
footskip=7.4mm,
%showframe
}
%FOR TABLES
\usepackage{float}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{siunitx}
%----------------------BEGIN-------------------------
\begin{document}
\begin{table}[H]
\small
\centering
\begin{tabular}{ll SSSS SS SS} %S centres
%\begin{tabular}{l|l ? S|S|S|S | S|S | S|S}
\toprule
& &
\multicolumn{4}{c}{Heading 1} & %&
\multicolumn{2}{c}{Heading 2} &
\multicolumn{2}{c}{Heading 3} \\
\cmidrule(rl){3-6}
\cmidrule(rl){7-8}
\cmidrule(rl){9-10}
Column 1& Column 2& {Sub 1} & {Sub 2} & {Sub 3} & {Sub 4} & {Sub 1} & {Sub 2} & {Sub 1} & {Sub 2} \\
\midrule
A1 = item1 & 0.0001 & 1 & 1 & 1 & 2 & 3 & 4 & 5 & 6 \\
%\hline
A2 = item2 & 0.0002 & 1 & 1 & 7 & 8 & 9 & 10 & 11 & 12 \\
%\hline
A3 = item3 & 0.0003 & 1 & 1 & 13 & 14 & 15 & 16 & 17 & 18 \\
\bottomrule
\end{tabular}
\caption{Test Table} \label{tbl:BPF}
\end{table}
\end{document}