
내 상사는 세 개의 수직 테이블을 하나의 수평/가로 테이블로 만들 것을 요청했습니다. 내 테이블의 코드(적어도 서식 지정 부분)는 다소 복잡했으며 이것이 가로 테이블에 대한 첫 번째 시도입니다. 불행하게도 나는 약간 막혔고 어디에서 잘못되었는지(열 너비 등) 알고 있다고 생각하지만 문제를 해결하는 방법을 잘 모르겠습니다. 나는 내가 얻고 싶은 것을 이해하기 위해 아래 테이블의 모형을 제공합니다.
여기 내 MWE가 있습니다
\documentclass{article}
\usepackage{pdflscape}
\usepackage{afterpage}
\usepackage{booktabs}
\usepackage{siuntix}
\usepackage{array}
\usepackage{ragged2e}
\usepackage{capt-of}% or use the larger `caption` package
\begin{document}
\afterpage{
\clearpage
\thispagestyle{empty}
\begin{landscape}
\begin{table}
\centering
\begin{tabular*}
\small
{
>{\RaggedRight\arraybackslash}p{.17\textwidth}
S *{3}{S[table-format=2.1] >{\footnotesize}S[table-format=3.2,input-symbols=()]} }
\caption {Descriptive Statistics (\%): Commerce, EBE and Science faculties}
\label{table:DSCF} \\
\toprule
{\bfseries Variable} &
\multicolumn{3}{c}{\bfseries Commerce}\\
\multicolumn{3}{c}{\bfseries EBE} \\
\multicolumn{3}{c}{\bfseries Science} \\
\multicolumn{3}{c}{\bfseries Total} \\
\cmidrule{2-13}
&&
\multicolumn{1}{C{.19\textwidth}}{\bfseries Graduated} & \multicolumn{1}{C{.19\textwidth}}{\bfseries Academically Excluded} &
\multicolumn{1}{C{.19\textwidth}}{\bfseries Censored}
\multicolumn{1}{C{.19\textwidth}}{\bfseries Graduated} & \multicolumn{1}{C{.19\textwidth}}{\bfseries Academically Excluded} &
\multicolumn{1}{C{.19\textwidth}}{\bfseries Censored}
\multicolumn{1}{C{.19\textwidth}}{\bfseries Graduated} & \multicolumn{1}{C{.19\textwidth}}{\bfseries Academically Excluded} &
\multicolumn{1}{C{.19\textwidth}}{\bfseries Censored}
\multicolumn{1}{C{.19\textwidth}}{\bfseries Graduated} & \multicolumn{1}{C{.19\textwidth}}{\bfseries Academically Excluded} &
\multicolumn{1}{C{.19\textwidth}}{\bfseries Censored}\\
\midrule
\bfseries Total & 50.1 & 7.5 & 42.4 & 35.8 & 21.6 & 42.7 & 46.4 & 26.1 & 27.5 & & 45.8 & 14.9 & 39.3 \\
\addlinespace
\bfseries Gender\\
Male & 49.6 & 8.7 & 41.7 & 36.4 & 21.9 & 41.7 & 44.0 & 31.2 & 24.9 & 44.3 & 17.3 & 38.5 \\
Female & 50.7 & 6.2 & 43.1 & 33.8 & 20.6 & 45.7 & 49.3 & 20.2 & 30.5 & 48.0 & 11.5 & 40.5 \\
\addlinespace
\bfseries Race\\
White & 59.8 & 3.0 & 37.2 & 50.8 & 7.8 & 41.3 & 64.5 & 5.1 & 30.4 & & 58.7 & 4.6 & 36.7 \\
Black & 38.7 & 13.1 & 48.2 & 22.2 &34.9& 43.0 & 31.0 & 44.5 & 24.5 & 32.5 & 26.3 &41.2(\\
Coloured & 49.8 & 7.4 & 42.8 & 36.4 & 21.9 & 41.6 & 40.2 & 30.6 & 29.2 & 44.5 & 16.1 & 39.5 \\
Indian/Asian & 48.9 & 7.9 & 43.3 & 32.7 & 20.5 & 46.9 & 32.7 & 20.5 & 46.9 & 44.6 & 13.3 & 42.1\\
\addlinespace
\bfseries Financial Aid\\
Ineligible for Financial Aid & 52.1 & 5.5 & 42.4 & 38.0 & 17.7 & 44.3 & 38.0 & 17.7 & 44.3 & 48.7 & 10.6 & 40.7 \\
Eligible for Financial Aid & 40.7 & 17.2 & 42.1 & 26.5 & 37.5 & 36.1 & 33.8 & 42.9 & 23.3 & 35.2 & 30.3 & 34.5 \\
\addlinespace
\bfseries Programme\\
Mainstream & 55.4 & 5.7 & 38.9 & 40.5 & 17.3 & 42.3 & 54.3 & 16.4 & 29.3 & 51.3 & 10.8 & 37.9 \\
Academic Development & 32.5 & 13.7 & 53.8 & 14.1 & 41.4 & 44.5 & 25.3 & 51.8 & 22.8 & 27.1 & 28.7 & 44.2 \\
\addlinespace
\bfseries English Home Language\\
Yes & 55.1 & 4.9 & 39.9 & 44.1 & 13.3 & 42.6 & 56.3 & 14.1 & 29.6 & 52.8 & 8.6 & 38.6 \\
No & 38.8 & 13.4 & 47.8 & 22.3 & 35.0 & 42.7 & 32.7 & 42.7 & 24.6 & 32.8 & 26.6 & 40.6 \\
\addlinespace
\bfseries School Quintile\\
1 & 34.6 & 30.8 & 34.6 & 14.1 & 49.3 & 36.6 & 34.0 & 45.3 & 20.8 & 26.1 & 42.6 & 31.3 \\
2 & 30.2 & 16.0 & 53.8 & 25.6 & 36.4 & 38.0 & 28.8 & 50.9 & 20.3 & 28.1 & 35.1 & 36.8 \\
3 & 32.0 & 17.5 & 50.5 & 21.7 & 41.9 & 36.5 & 30.0 & 45.8 & 24.2 & 27.7 & 35.3 & 37.0 \\
4 & 37.7 & 17.7 & 44.5 & 17.7 & 38.0 & 44.3 & 30.0 & 46.7 & 23.3 & 29.5 & 32.0 & 38.5 \\
5 & 52.0 & 6.9 & (41.1 & 41.0 & 16.2 & 42.9 & 54.3 & 14.8 & 31.0 & 49.2 & 12.0 & 38.9 \\
Independent & 52.5 & 5.3 & 42.2 & 40.7 & 13.9 & 45.5 & 54.3 &14.8 & 31.0 50.4 & 8.6 & 41.0 \\
\addlinespace
{\bfseries Province}\\
Western Cape & 55.1 & 5.9 &39.0 & 42.1 &16.2 &41.7 & 52.0 &20.0 & 28.0 & 51.3 & 11.6 &37.0 \\
Non-Western Cape &46.8 & 8.6 & 44.6 & 31.6 & 25.1 & 43.3 & 41.5 & 31.5 & 27.1 & 41.9 & 17.2 &41.0\\
\addlinespace
{\bfseries Year of First Registration} \\
{2006} 87.8 & 11.3 & 0.9 & 70.3 & 29.0 & 0.7 & 69.5 & 28.2 & 2.3 & 79.9 & 18.9 &1.2 \\
{2007} 88.2 & 10.1 & 1.7 & 68.7 & 30.0 & 1.4 & 68.5 & 30.8 & 0.7 & 79.4 &19.2 &1.4\\
{2008} 87.1 & 10.3 & 2.6 & 63.6 & 30.6 & 5.8 & 66.2 & 32.3 & 1.6 & 76.7 & 20.3 & 3.0 \\
{2009} 80.9 & 9.7 & 9.4 & 51.2 & 32.3 &16.5 & 51.9 & 43.9 & 4.2 & 64.9 & 24.9 & 10.2 \\
{2010} 62.6 & 6.4 & 31.1 & 36.8 & 19.0 & 44.2 & 69.8 & 21.0 & 9.3 & 57.5 & 12.7 & 29.8 \\
{2011} 15.8 & 7.2 & 77.0 & 0.0 & 18.2 & 81.8 & 37.3 & 23.4 & 39.8 & 15.3 & 12.8 & 71.9 \\
{2012} 0.0 & 5.4 & 94.6 & 0.0 & 7.5 & 92.5 & 0.0 & 13.4 & 86.6 & 0.0 & 7.5 & 92.5 \\
{2013} 0.0 & 1.7 & 98.3 & 0.0 & 4.9 & 95.1 & 0.0 & 5.1 & 94.9 & 0.0 & 3.0 & 97.0 \\
\end{tabular*}
\end{table}
\end{landscape}
\clearpage
}
\end{document}
답변1
다소 긴 열 제목(Graduated, Academically Excluded, Censored)을 약어(G, AE, C)로 바꾸고 캡션에 키를 설명하는 것이 좋습니다. 그러면 가로 페이지의 모든 열을 쉽게 맞출 수 있습니다.
그 밖에도 여기저기서 소소한 변화가 많이 있습니다. 다 기억나는지는 모르겠지만,
- 새로운 열 사양. 1개의
p
열 뒤에 12개의S
열이 있습니다. - 몇 개의 숫자에서 일부 괄호를 제거했습니다.
- 일부 추가 항목을 제거하고
&
필요한 경우 일부도 추가했습니다. longtable
사용. 표가 너무 길어서 한 페이지에 다 들어갈 수 없을 것 같아요.- 최상위 열 제목(Commerce, EBE 등) 각각 뒤에 줄 바꿈이 있었으며 이는 이어야 합니다
&
. cmidrule
하나의 긴 대신 약간의 트리밍이 포함된 4개의 별도 s입니다.
\documentclass{article}
\usepackage{pdflscape,ragged2e,array,siunitx,longtable,booktabs}
\usepackage{afterpage}
\usepackage{capt-of}% or use the larger `caption` package
\begin{document}
\begin{landscape}
\centering
\small
\begin{longtable}{
>{\RaggedRight\arraybackslash}p{.35\textwidth}
*{12}{S[table-format=2.1]}}
\caption{Descriptive Statistics (\%): Commerce, EBE and Science faculties. Key: \textbf{G}: Graduate, \textbf{AE}: Academically Excluded, \textbf{C}: Censored}
\label{table:DSCF} \\
\toprule
{\bfseries Variable} &
\multicolumn{3}{c}{\bfseries Commerce} &
\multicolumn{3}{c}{\bfseries EBE} &
\multicolumn{3}{c}{\bfseries Science} &
\multicolumn{3}{c}{\bfseries Total} \\
\cmidrule(rl){2-4}
\cmidrule(rl){5-7}
\cmidrule(rl){8-10}
\cmidrule(rl){11-13}
&
{\bfseries G} & {\bfseries AE} &
{\bfseries C} &
{\bfseries G} & {\bfseries AE} &
{\bfseries C} &
{\bfseries G} & {\bfseries AE} &
{\bfseries C} &
{\bfseries G} & {\bfseries AE} &
{\bfseries C}\\
\midrule
\bfseries Total & 50.1 & 7.5 & 42.4 & 35.8 & 21.6 & 42.7 & 46.4 & 26.1 & 27.5 & 45.8 & 14.9 & 39.3 \\
\addlinespace
\bfseries Gender\\
Male & 49.6 & 8.7 & 41.7 & 36.4 & 21.9 & 41.7 & 44.0 & 31.2 & 24.9 & 44.3 & 17.3 & 38.5 \\
Female & 50.7 & 6.2 & 43.1 & 33.8 & 20.6 & 45.7 & 49.3 & 20.2 & 30.5 & 48.0 & 11.5 & 40.5 \\
\addlinespace
\bfseries Race\\
White & 59.8 & 3.0 & 37.2 & 50.8 & 7.8 & 41.3 & 64.5 & 5.1 & 30.4 & 58.7 & 4.6 & 36.7 \\
Black & 38.7 & 13.1 & 48.2 & 22.2 &34.9& 43.0 & 31.0 & 44.5 & 24.5 & 32.5 & 26.3 &41.2\\
Coloured & 49.8 & 7.4 & 42.8 & 36.4 & 21.9 & 41.6 & 40.2 & 30.6 & 29.2 & 44.5 & 16.1 & 39.5 \\
Indian/Asian & 48.9 & 7.9 & 43.3 & 32.7 & 20.5 & 46.9 & 32.7 & 20.5 & 46.9 & 44.6 & 13.3 & 42.1\\
\addlinespace
\bfseries Financial Aid\\
Ineligible for Financial Aid & 52.1 & 5.5 & 42.4 & 38.0 & 17.7 & 44.3 & 38.0 & 17.7 & 44.3 & 48.7 & 10.6 & 40.7 \\
Eligible for Financial Aid & 40.7 & 17.2 & 42.1 & 26.5 & 37.5 & 36.1 & 33.8 & 42.9 & 23.3 & 35.2 & 30.3 & 34.5 \\
\addlinespace
\bfseries Programme\\
Mainstream & 55.4 & 5.7 & 38.9 & 40.5 & 17.3 & 42.3 & 54.3 & 16.4 & 29.3 & 51.3 & 10.8 & 37.9 \\
Academic Development & 32.5 & 13.7 & 53.8 & 14.1 & 41.4 & 44.5 & 25.3 & 51.8 & 22.8 & 27.1 & 28.7 & 44.2 \\
\addlinespace
\bfseries English Home Language\\
Yes & 55.1 & 4.9 & 39.9 & 44.1 & 13.3 & 42.6 & 56.3 & 14.1 & 29.6 & 52.8 & 8.6 & 38.6 \\
No & 38.8 & 13.4 & 47.8 & 22.3 & 35.0 & 42.7 & 32.7 & 42.7 & 24.6 & 32.8 & 26.6 & 40.6 \\
\addlinespace
\bfseries School Quintile\\
1 & 34.6 & 30.8 & 34.6 & 14.1 & 49.3 & 36.6 & 34.0 & 45.3 & 20.8 & 26.1 & 42.6 & 31.3 \\
2 & 30.2 & 16.0 & 53.8 & 25.6 & 36.4 & 38.0 & 28.8 & 50.9 & 20.3 & 28.1 & 35.1 & 36.8 \\
3 & 32.0 & 17.5 & 50.5 & 21.7 & 41.9 & 36.5 & 30.0 & 45.8 & 24.2 & 27.7 & 35.3 & 37.0 \\
4 & 37.7 & 17.7 & 44.5 & 17.7 & 38.0 & 44.3 & 30.0 & 46.7 & 23.3 & 29.5 & 32.0 & 38.5 \\
5 & 52.0 & 6.9 & 41.1 & 41.0 & 16.2 & 42.9 & 54.3 & 14.8 & 31.0 & 49.2 & 12.0 & 38.9 \\
Independent & 52.5 & 5.3 & 42.2 & 40.7 & 13.9 & 45.5 & 54.3 &14.8 & 31.0 & 50.4 & 8.6 & 41.0 \\
\addlinespace
{\bfseries Province}\\
Western Cape & 55.1 & 5.9 &39.0 & 42.1 &16.2 &41.7 & 52.0 &20.0 & 28.0 & 51.3 & 11.6 &37.0 \\
Non-Western Cape &46.8 & 8.6 & 44.6 & 31.6 & 25.1 & 43.3 & 41.5 & 31.5 & 27.1 & 41.9 & 17.2 &41.0\\
\addlinespace
{\bfseries Year of First Registration} \\
{2006} & 87.8 & 11.3 & 0.9 & 70.3 & 29.0 & 0.7 & 69.5 & 28.2 & 2.3 & 79.9 & 18.9 &1.2 \\
{2007} & 88.2 & 10.1 & 1.7 & 68.7 & 30.0 & 1.4 & 68.5 & 30.8 & 0.7 & 79.4 &19.2 &1.4\\
{2008} & 87.1 & 10.3 & 2.6 & 63.6 & 30.6 & 5.8 & 66.2 & 32.3 & 1.6 & 76.7 & 20.3 & 3.0 \\
{2009} & 80.9 & 9.7 & 9.4 & 51.2 & 32.3 &16.5 & 51.9 & 43.9 & 4.2 & 64.9 & 24.9 & 10.2 \\
{2010} & 62.6 & 6.4 & 31.1 & 36.8 & 19.0 & 44.2 & 69.8 & 21.0 & 9.3 & 57.5 & 12.7 & 29.8 \\
{2011} & 15.8 & 7.2 & 77.0 & 0.0 & 18.2 & 81.8 & 37.3 & 23.4 & 39.8 & 15.3 & 12.8 & 71.9 \\
{2012} & 0.0 & 5.4 & 94.6 & 0.0 & 7.5 & 92.5 & 0.0 & 13.4 & 86.6 & 0.0 & 7.5 & 92.5 \\
{2013} & 0.0 & 1.7 & 98.3 & 0.0 & 4.9 & 95.1 & 0.0 & 5.1 & 94.9 & 0.0 & 3.0 & 97.0 \\
\end{longtable}
\end{landscape}
\end{document}
두 번째 옵션
첫 번째 열의 항목을 다시 작성/단축하고 줄이면 \tabcolsep
실제로 세로 모드에서 전체 항목을 한 페이지에 압축할 수 있습니다. 실제 문서의 텍스트 블록이 기본값보다 넓다면 article
더 많은 작업을 수행해야 하므로 아래 코드보다 더 넓게 만들 수 있습니다. (스크린샷의 프레임은 showframe
패키지를 로드할 때 나온 것입니다. 이는 표가 실제로 텍스트 블록의 너비 내에 있다는 것을 보여주기 위한 것입니다.)
\documentclass{article}
\usepackage{ragged2e,array,siunitx,longtable,booktabs}
\begin{document}
\begin{table}
\centering
\small
\setlength{\tabcolsep}{3.7pt}
\caption{Descriptive Statistics (\%): Commerce, EBE and Science faculties. Key: \textbf{G}: Graduate, \textbf{AE}: Academically Excluded, \textbf{C}: Censored}
\label{table:DSCF}
\begin{tabular}{
>{\RaggedRight\arraybackslash}p{.15\textwidth}
*{12}{S[table-format=2.1]}}
\toprule
{\bfseries Variable} &
\multicolumn{3}{c}{\bfseries Commerce} &
\multicolumn{3}{c}{\bfseries EBE} &
\multicolumn{3}{c}{\bfseries Science} &
\multicolumn{3}{c}{\bfseries Total} \\
\cmidrule(rl){2-4}
\cmidrule(rl){5-7}
\cmidrule(rl){8-10}
\cmidrule(rl){11-13}
&
{\bfseries G} & {\bfseries AE} &
{\bfseries C} &
{\bfseries G} & {\bfseries AE} &
{\bfseries C} &
{\bfseries G} & {\bfseries AE} &
{\bfseries C} &
{\bfseries G} & {\bfseries AE} &
{\bfseries C}\\
\midrule
\bfseries Total & 50.1 & 7.5 & 42.4 & 35.8 & 21.6 & 42.7 & 46.4 & 26.1 & 27.5 & 45.8 & 14.9 & 39.3 \\
\addlinespace
\bfseries Gender\\
Male & 49.6 & 8.7 & 41.7 & 36.4 & 21.9 & 41.7 & 44.0 & 31.2 & 24.9 & 44.3 & 17.3 & 38.5 \\
Female & 50.7 & 6.2 & 43.1 & 33.8 & 20.6 & 45.7 & 49.3 & 20.2 & 30.5 & 48.0 & 11.5 & 40.5 \\
\addlinespace
\bfseries Race\\
White & 59.8 & 3.0 & 37.2 & 50.8 & 7.8 & 41.3 & 64.5 & 5.1 & 30.4 & 58.7 & 4.6 & 36.7 \\
Black & 38.7 & 13.1 & 48.2 & 22.2 &34.9& 43.0 & 31.0 & 44.5 & 24.5 & 32.5 & 26.3 &41.2\\
Coloured & 49.8 & 7.4 & 42.8 & 36.4 & 21.9 & 41.6 & 40.2 & 30.6 & 29.2 & 44.5 & 16.1 & 39.5 \\
Indian/Asian & 48.9 & 7.9 & 43.3 & 32.7 & 20.5 & 46.9 & 32.7 & 20.5 & 46.9 & 44.6 & 13.3 & 42.1\\
\addlinespace
\multicolumn{4}{l}{\bfseries Financial Aid}\\
Ineligible& 52.1 & 5.5 & 42.4 & 38.0 & 17.7 & 44.3 & 38.0 & 17.7 & 44.3 & 48.7 & 10.6 & 40.7 \\
Eligible & 40.7 & 17.2 & 42.1 & 26.5 & 37.5 & 36.1 & 33.8 & 42.9 & 23.3 & 35.2 & 30.3 & 34.5 \\
\addlinespace
\multicolumn{4}{l}{\bfseries Programme}\\
Mainstream & 55.4 & 5.7 & 38.9 & 40.5 & 17.3 & 42.3 & 54.3 & 16.4 & 29.3 & 51.3 & 10.8 & 37.9 \\
Academic Dev. & 32.5 & 13.7 & 53.8 & 14.1 & 41.4 & 44.5 & 25.3 & 51.8 & 22.8 & 27.1 & 28.7 & 44.2 \\
\addlinespace
\multicolumn{4}{l}{\bfseries English Home Language}\\
Yes & 55.1 & 4.9 & 39.9 & 44.1 & 13.3 & 42.6 & 56.3 & 14.1 & 29.6 & 52.8 & 8.6 & 38.6 \\
No & 38.8 & 13.4 & 47.8 & 22.3 & 35.0 & 42.7 & 32.7 & 42.7 & 24.6 & 32.8 & 26.6 & 40.6 \\
\addlinespace
\multicolumn{4}{l}{\bfseries School Quintile}\\
1 & 34.6 & 30.8 & 34.6 & 14.1 & 49.3 & 36.6 & 34.0 & 45.3 & 20.8 & 26.1 & 42.6 & 31.3 \\
2 & 30.2 & 16.0 & 53.8 & 25.6 & 36.4 & 38.0 & 28.8 & 50.9 & 20.3 & 28.1 & 35.1 & 36.8 \\
3 & 32.0 & 17.5 & 50.5 & 21.7 & 41.9 & 36.5 & 30.0 & 45.8 & 24.2 & 27.7 & 35.3 & 37.0 \\
4 & 37.7 & 17.7 & 44.5 & 17.7 & 38.0 & 44.3 & 30.0 & 46.7 & 23.3 & 29.5 & 32.0 & 38.5 \\
5 & 52.0 & 6.9 & 41.1 & 41.0 & 16.2 & 42.9 & 54.3 & 14.8 & 31.0 & 49.2 & 12.0 & 38.9 \\
Independent & 52.5 & 5.3 & 42.2 & 40.7 & 13.9 & 45.5 & 54.3 &14.8 & 31.0 & 50.4 & 8.6 & 41.0 \\
\addlinespace
\multicolumn{4}{l}{\bfseries Western cape province}\\
Yes & 55.1 & 5.9 &39.0 & 42.1 &16.2 &41.7 & 52.0 &20.0 & 28.0 & 51.3 & 11.6 &37.0 \\
No &46.8 & 8.6 & 44.6 & 31.6 & 25.1 & 43.3 & 41.5 & 31.5 & 27.1 & 41.9 & 17.2 &41.0\\
\addlinespace
\multicolumn{4}{l}{\bfseries Year of First Registration} \\
{2006} & 87.8 & 11.3 & 0.9 & 70.3 & 29.0 & 0.7 & 69.5 & 28.2 & 2.3 & 79.9 & 18.9 &1.2 \\
{2007} & 88.2 & 10.1 & 1.7 & 68.7 & 30.0 & 1.4 & 68.5 & 30.8 & 0.7 & 79.4 &19.2 &1.4\\
{2008} & 87.1 & 10.3 & 2.6 & 63.6 & 30.6 & 5.8 & 66.2 & 32.3 & 1.6 & 76.7 & 20.3 & 3.0 \\
{2009} & 80.9 & 9.7 & 9.4 & 51.2 & 32.3 &16.5 & 51.9 & 43.9 & 4.2 & 64.9 & 24.9 & 10.2 \\
{2010} & 62.6 & 6.4 & 31.1 & 36.8 & 19.0 & 44.2 & 69.8 & 21.0 & 9.3 & 57.5 & 12.7 & 29.8 \\
{2011} & 15.8 & 7.2 & 77.0 & 0.0 & 18.2 & 81.8 & 37.3 & 23.4 & 39.8 & 15.3 & 12.8 & 71.9 \\
{2012} & 0.0 & 5.4 & 94.6 & 0.0 & 7.5 & 92.5 & 0.0 & 13.4 & 86.6 & 0.0 & 7.5 & 92.5 \\
{2013} & 0.0 & 1.7 & 98.3 & 0.0 & 4.9 & 95.1 & 0.0 & 5.1 & 94.9 & 0.0 & 3.0 & 97.0 \\
\end{tabular}
\end{table}
\end{document}