
다음과 같이 몇 가지 숫자와 전체 결과가 포함된 표를 만들려고 합니다.
Age Female Male Total
----------------------------
Under 10 5 8 13
10-30 57 61 118
30-60 5 1 6
Over 60 3 0 3
--- --- ---
TOTAL 70 70 140
----------------------------
이 세 ---
줄은 행의 절반에 걸쳐 있는 일종의 밑줄을 나타냅니다.
표선의 길이를 그리거나 지정하려면 어떻게 해야 합니까?
답변1
이 명령에는 \cmidrule
축소할 면을 지정할 수 있는 괄호 안에 선택적 인수가 있습니다.
귀하의 테이블을 달성하는 방법은 다음과 같습니다
\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{lrrr}
Age & Female & Male & Total \\
\midrule
Under 10 & 5 & 8 & 13 \\
10-30 & 57 & 61 & 118 \\
30-60 & 5 & 1 & 6 \\
Over 60 & 3 & 0 & 3 \\
\cmidrule(l){2-2}\cmidrule(l){3-3}\cmidrule(l){4-4}
TOTAL & 70 & 70 & 140 \\
\bottomrule
\end{tabular}
\end{document}
다음은 고정 열이 있고 길이가 \cmidrule
고정 값만큼 감소되는 또 다른 버전입니다.
\documentclass{article}
\usepackage{booktabs,array}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}m{#1}}
\begin{document}
\begin{tabular}{l*{3}{R{1.2cm}}}
Age & Female & Male & Total \\
\midrule
Under 10 & 5 & 8 & 13 \\
10-30 & 57 & 61 & 118 \\
30-60 & 5 & 1 & 6 \\
Over 60 & 3 & 0 & 3 \\
\cmidrule(l{.7cm}){2-2}\cmidrule(l{.7cm}){3-3}\cmidrule(l{.7cm}){4-4}
TOTAL & 70 & 70 & 140 \\
\bottomrule
\end{tabular}
\end{document}
답변2
다음 예에서는 총 합계 위에 규칙을 추가합니다. 규칙은 양쪽에서 \fboxsep
. MWE는 karlkoeller's에서 가져왔습니다.답변.
\documentclass{article}
\usepackage{booktabs}
\newcommand*{\oline}[1]{%
\kern-\fboxsep
\vbox{%
\hrule
\kern1ex
\hbox{%
\kern\fboxsep
#1%
\kern\fboxsep
}%
}%
\kern-\fboxsep
}
\begin{document}
\begin{tabular}{lrrr}
Age & Female & Male & Total \\
\midrule
Under 10 & 5 & 8 & 13 \\
10--30 & 57 & 61 & 118 \\
30--60 & 5 & 1 & 6 \\
Over 60 & 3 & 0 & 3 \\
TOTAL & \oline{70} & \oline{70} & \oline{140} \\
\bottomrule
\end{tabular}
\end{document}