我不太清楚我的问题是什么,但我会尽力解释。我一直在尝试整理一个大型的景观表来总结一些数据。它们都来自类似的来源,所以如果可以的话,我想把它们都放在一个表中。但是,它超过了两页。所以我尝试切换到 longtable 环境,这导致整个事情崩溃了。它给了我大约 50 个“未定义的控制序列”错误。
任何帮助都非常受欢迎。
这是我的代码:
\usepackage{lscape}
\usepackage{afterpage}
\usepackage{capt-of}% or use the larger `caption` package
\usepackage{booktabs}
\usepackage{array}
\usepackage{multirow}
\usepackage{longtable}
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}
\afterpage{%
\clearpage% Flush earlier floats (otherwise order might not be correct)
\thispagestyle{empty}% empty page style (?)
\begin{landscape}% Landscape page
\centering % Center table
\ra{1.2}
%\captionof{table}{Varieties of Schooling in the Towns, 1834-40}% Add 'table' caption
\scalebox{1}{
\begin{longtable}{@{} rcrrrrrrcrrcrr @{}}
\caption{Summary of School Provision from Statistical Societies, 1834-40.\label{long}}\\
\toprule[0.8mm]
& \phantom{abc} & \multicolumn{6}{c}{Day Scholars} & \phantom{abc} & \multicolumn{2}{c}{Sunday Scholars} & \phantom{abc} & \multicolumn{2}{c}{Totals} \\
\cmidrule{3-8}\cmidrule{10-11}\cmidrule{13-14}
& \phantom{abc} & Dame & Common & Superior & Infant & Public & \% Under 5 & & Total & \% Bi-enrolled & \phantom{abc} & Scholars & 1831 Pop. \\ \midrule
\endhead
\bottomrule[0.8mm]
\endfoot
\textit{Manchester (1834)} \\
M && 1,939 & 4,107 & 1,350 & 345 & 2,481 & \multirow{2}{*}{---} && 16,303 & \multirow{2}{*}{30\%} && 21,634 & 88,661\\
F && 2,783 & 2,795 & 1,579 & 304 & 973 &&& 16,893 &&&20,259&98,361\\
\textit{Pendleton (1835)} \\
M && 69 & 93 & 15 & 20 & 280 & \multirow{2}{*}{15\%} && 814 & \multirow{2}{*}{53\%} && 860 & 4023\\
F && 159 & 131 & 72 & 45 & 273 &&& 872 &&&1,090&4412\\
\textit{Liverpool (1835)} \\
M && 2,168 & 3,421 & 2,111 & 1,118 & 6,582 & \multirow{2}{*}{14\%} && 8,188 & \multirow{2}{*}{76\%} && 15,465& 76,626 \\
F && 3,072 & 2,675 & 1,969 & 1,087 & 4,713 &&& 7,250 &&&15,256 &88,549\\
\textit{Bury (1835)} \\
M && 258 & 535 & 51 & 137 & 272 & \multirow{2}{*}{20\%} && 1,899 & \multirow{2}{*}{27\%} && 2,639 &7,439 \\
F && 582 & 273 & 123 & 106 & 137 &&& 2,325 &&&2,918&7,647\\
\textit{Salford (1835)} \\
M && 563 & 1215 & 382 & 170 & 715 & \multirow{2}{*}{14\%} && 4826 & \multirow{2}{*}{35\%} && 6,182 & 24,212 \\
F && 980 & 599 & 500 & 203 & 688 &&& 4928 &&&6,173 & 26,598\\
\textit{York (1836)} \\
M && 270 & 300 & 264 & 205 & 1,155 & \multirow{2}{*}{13\%} && 1,722 & \multirow{2}{*}{75\%} && 2,625 & 11,989 \\
F && 475 & 249 & 452 & 211 & 1,126 &&& 1,641 &&&2,923&14,271\\
\textit{Westminster (1837)} \\
M && 125 & 402 & 475 & 362 & 633 & \multirow{2}{*}{22\%} && 573 & \multirow{2}{*}{57\%} && 2,243&20,781 \\
F && 215 & 382 & 557 & 298 & 568 &&& 982 &&& 2,442& 22,215\\
\textit{Rutland (1838)} \\
M && 277 & 272 & 85 & 0 & 941 & \multirow{2}{*}{16\%} && 1,650 & \multirow{2}{*}{60\%} && 2,235& 9,721 \\
F && 401 & 268 & 51 & 0 & 669 &&& 1,546 &&& 2,007& 9,664\\
\textit{Kingston-upon-Hull (1839)} \\
M/F && \multicolumn{5}{c}{--------------------- 8,988 ---------------------} & 11\% && 6,800 & 95\% && 9,328 & 32,958 \\
\textit{Bristol (1840)} \\
M && 1,357 & 1,679 & 510 & 1,004 & 2,741 & \multirow{2}{*}{22\%} && 5,780 & \multirow{2}{*}{37\%} && 10,932 & 46,535 \\
F && 1,658 & 1,800 & 230 & 701 & 2,180 &&& 5,904 &&& 10,289 & 57,351\\
\textit{Birmingham (1840)} \\
M && 1,829 & 2,007 & 989 & 471 & 2,100 & \multirow{2}{*}{20\%} && 9,284 & \multirow{2}{*}{25\%} && 14,359 & 71,756 \\
F && 2,071 & 2,273 & 1,177 & 332 & 1,231 &&& 7,473 &&& 12,690 & 75,230\\
\end{longtable}}
\end{landscape}
\clearpage% Flush page
}
它本来应该是这样的,只不过它比我想要的更挤,而且没有留下引用的空间:
再次,我们非常欢迎任何帮助。提前谢谢您。
答案1
您的表格结构相当复杂,很大程度上是因为它有三列 [3!] 完全是空的,因此除了造成代码混乱之外,没有其他作用。我会删除全空的列以简化问题。
我还将为 10 个数据列使用一种列类型,该列类型对(显式或隐式)小数标记执行对齐。该S
列类型可以完成这项工作;它还可以处理插入(“逗号”)作为千位分隔符的任务,
。
以下屏幕截图显示了采用上述建议后表格的前 15 行左右。
\documentclass{ociamthesis}
% paper size: a4paper
% width and height of text block: 6.0" and 9.0"
\usepackage{pdflscape}
\usepackage{afterpage}
\usepackage{capt-of}
\usepackage{booktabs}
\usepackage{array}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{siunitx} % for 'S' column type
\newcolumntype{T}[1]{S[table-format=#1]}
\sisetup{group-separator={,},group-four-digits}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}}
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}
\begin{document}
\afterpage{\clearpage%
%\thispagestyle{empty} % I wouldn't do this
\begin{landscape}
%\ra{1.2} % better to use selective spacing via '\addlinespace' (see below)
\setlength\LTcapwidth\textwidth
\begin{longtable}{@{} r *{5}{T{4.0}} c T{5.0} c T{5.0}T{5.0} @{}}
\caption{Summary of School Provision from Statistical
Societies, 1834--40.}\label{long}\\
\toprule
& \multicolumn{6}{c}{Day Scholars}
& \multicolumn{2}{c}{Sunday Scholars}
& \multicolumn{2}{c@{}}{Totals} \\
\cmidrule(lr){2-7}\cmidrule(lr){8-9}\cmidrule(l){10-11}
& \mc{Dame} & \mc{Common} & \mc{Superior} & \mc{Infant}
& \mc{Public} & \mc{\% Under 5} & \mc{Total}
& \mc{\% Bi-enrolled} & \mc{Scholars} & \multicolumn{1}{c@{}}{1831 Pop.} \\
\midrule
\endfirsthead
\multicolumn{5}{@{}l}{Table \thetable, cont'd from previous page}\\
\addlinespace
\toprule
& \multicolumn{6}{c}{Day Scholars}
& \multicolumn{2}{c}{Sunday Scholars}
& \multicolumn{2}{c@{}}{Totals} \\
\cmidrule(lr){2-7}\cmidrule(lr){8-9}\cmidrule(l){10-11}
& \mc{Dame} & \mc{Common} & \mc{Superior} & \mc{Infant}
& \mc{Public} & \mc{\% Under 5} & \mc{Total}
& \mc{\% Bi-enrolled} & \mc{Scholars} & \multicolumn{1}{c@{}}{1831 Pop.} \\
\midrule
\endhead
\midrule
\multicolumn{11}{r@{}}{\footnotesize (continued on following page)}
\endfoot
\bottomrule
\endlastfoot
%% body of longtable
\textit{Manchester (1834)} \\
M & 1939 & 4107 & 1350 & 345 & 2481 & \multirow{2}{*}{---}
& 16303 & \multirow{2}{*}{30\%}
& 21634 & 88661\\
F & 2783 & 2795 & 1579 & 304 & 973 & & 16893
& & 20259 & 98361\\
\addlinespace
\textit{Pendleton (1835)} \\
M & 69 & 93 & 15 & 20 & 280 & \multirow{2}{*}{15\%} & 814 & \multirow{2}{*}{53\%} & 860 & 4023\\
F & 159 & 131 & 72 & 45 & 273 && 872 &&1090&4412\\
\addlinespace
\textit{Liverpool (1835)} \\
M & 2168 & 3421 & 2111 & 1118 & 6582 & \multirow{2}{*}{14\%} & 8188 & \multirow{2}{*}{76\%} & 15465& 76626 \\
F & 3072 & 2675 & 1969 & 1087 & 4713 && 7250 &&15256 &88549\\
\addlinespace
\textit{Bury (1835)} \\
M & 258 & 535 & 51 & 137 & 272 & \multirow{2}{*}{20\%} & 1899 & \multirow{2}{*}{27\%} & 2639 &7439 \\
F & 582 & 273 & 123 & 106 & 137 && 2325 &&2918&7647\\
\addlinespace
\textit{Salford (1835)} \\
M & 563 & 1215 & 382 & 170 & 715 & \multirow{2}{*}{14\%} & 4826 & \multirow{2}{*}{35\%} & 6182 & 24212 \\
F & 980 & 599 & 500 & 203 & 688 && 4928&&6173 & 26598\\
\addlinespace
\textit{York (1836)} \\
M & 270 & 300 & 264 & 205 & 1155 & \multirow{2}{*}{13\%} & 1722 & \multirow{2}{*}{75\%} & 2625 & 11989 \\
F & 475 & 249 & 452 & 211 & 1126 && 1641 &&2923&14271\\
\addlinespace
\textit{Westminster (1837)} \\
M & 125 & 402 & 475 & 362 & 633 & \multirow{2}{*}{22\%} & 573 & \multirow{2}{*}{57\%} & 2243&20781 \\
F & 215 & 382 & 557 & 298 & 568 && 982 && 2442& 22215\\
%\addlinespace
\pagebreak
\textit{Rutland (1838)} \\
M & 277 & 272 & 85 & 0 & 941 & \multirow{2}{*}{16\%} & 1650 & \multirow{2}{*}{60\%} & 2235& 9721 \\
F & 401 & 268 & 51 & 0 & 669 && 1546 && 2007& 9664\\
\addlinespace
\multicolumn{4}{@{}l}{\textit{Kingston-upon-Hull (1839)}} \\
M\&F & \multicolumn{5}{c}{------------------------ 8{,}988 ------------------------} & 11\% & 6800 & 95\% & 9328 & 32958 \\
\addlinespace
\textit{Bristol (1840)} \\
M & 1357 & 1679 & 510 & 1004 & 2741 & \multirow{2}{*}{22\%} & 5780 & \multirow{2}{*}{37\%} & 10932 & 46535 \\
F & 1658 & 1800 & 230 & 701 & 2180 && 5904 && 10289 & 57351\\
\addlinespace
\textit{Birmingham (1840)} \\
M & 1829 & 2007 & 989 & 471 & 2100 & \multirow{2}{*}{20\%} & 9284 & \multirow{2}{*}{25\%} & 14359 & 71756 \\
F & 2071 & 2273 & 1177 & 332 & 1231 && 7473 && 12690 & 75230\\
\end{longtable}
\end{landscape}
}
\end{document}