Longtable Assist-未定义的控制序列

Longtable Assist-未定义的控制序列

我正在尝试为我的论文制作一些表格,但在尝试将表格变成长表格时,总是遇到问题。虽然我可以让表格在单独的文档中工作,但当它在我的论文中时似乎会出现问题。

我不断收到错误“未定义的控制序列”。 \begin{longtable}

另外,限制表格间距的最佳方法是什么,例如确保每行之间没有太大的间隙。

这是表格

\documentclass[12pt]{thesis} 

\usepackage{titlesec}
   \titleformat{\chapter}
      {\normalfont\large}{Chapter \thechapter:}{1em}{}

\usepackage{footnote}
\usepackage{todonotes}
\usepackage{adjustbox}
\graphicspath{ {images/} }
\usepackage{longtable}
\usepackage{booktabs} ... more after this 

    \begin{center}
\begin{longtable}{lllll}
        \caption[Totals of listed buildings per category in each council from 2010.]{Listed Building per category.} \label{LBperCat} \\

    \hline Local Authority                        & Category A & Category B & Category C & Totals \\ \hline 
    \endfirsthead

    \multicolumn{5}{c}%
    {{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\
    Local Authority                        & Category A & Category B & Category C & Totals \\ \hline 
    \endhead

    \hline \multicolumn{5}{|r|}{{Continued on next page}} \\ \hline
    \endfoot

    \hline \hline
    \endlastfoot
    Aberdeen & 68 & 679 & 464 & 1211 \\
    Abredeenshire & 208 & 1640 & 1948 & 3796 \\
    Angus \& Bute & 96 & 1019 & 1035 & 2150 \\
    Argyll \& Bute & 143 & 988 & 738 & 1869 \\
    Clackmannan & 17 & 134 & 152 & 303 \\
    Comhairle Nan Eilean Siar & 19 & 172 & 84 & 275 \\
    Dumfries \& Galloway & 224 & 1798 & 1382 & 3404 \\
    Dundee & 82 & 564 & 247 & 893 \\
    East AYRSHIRE & 45 & 339 & 364 & 748 \\
    East Dunbartonshire & 16 & 89 & 75 & 180 \\
    East Lothian & 136 & 1083 & 602 & 1821 \\
    East Refrenshire & 5 & 93 & 37 & 135 \\
    Edinburgh & 910 & 2646 & 1290 & 4846 \\
    Falkirk & 27 & 195 & 128 & 350 \\
    Fife & 212 & 2198 & 2549 & 4959 \\
    Glasgow & 281 & 1273 & 286 & 1840 \\
    Highland & 186 & 1669 & 1161 & 3016 \\
    Inverclyde & 25 & 129 & 91 & 245 \\
    Loch Lomond \& Trossachs National Park & 27 & 208 & 335 & 570 \\
    Midlothian & 71 & 315 & 327 & 713 \\
    Moray & 117 & 768 & 785 & 1670 \\
    North Ayrshire & 41 & 406 & 391 & 838 \\
    North Lanarkshire & 10 & 147 & 155 & 312 \\
    Orkney Islands & 24 & 295 & 313 & 632 \\
    Perth \& Kincorss & 160 & 1438 & 1500 & 3098 \\
    Renfrewshire & 39 & 343 & 185 & 567 \\
    Scottish Borders & 182 & 1247 & 1560 & 2989 \\
    Shetland & 13 & 173 & 158 & 344 \\
    South Ayrshrie & 74 & 438 & 429 & 941 \\
    South Lanarkshire & 92 & 544 & 443 & 1079 \\
    Stirling & 80 & 561 & 530 & 1171 \\
    West Dunbartonshire & 16 & 83 & 39 & 138 \\
    West Lothian & 43 & 215 & 179 & 437 \\ 
    Totals & 3689& 23889 & 19962 & 47540 \\ 
\end{longtable}
\end{center}

任何帮助/解决方案都将非常棒..我还需要制作 45 张与此类似的桌子。

答案1

这或多或少是题外的答案

  • 相反,thesis我使用book文档类
  • \usepackage{booktabs}删除序言后的虚假文字
  • 添加\begin{document}并`\end{document}
  • 添加两个新包:makecellsiunitx(通过它们的使用,表格变得更加一致)
  • 使用在中定义的水平规则booktabs
  • S对带有数字的列使用列类型
  • 第一列中的长名称使用“\makecell{...}˙˙”分成两行

结果:

在此处输入图片描述

在此处输入图片描述

在此处输入图片描述

希望姆韦下面将帮助您找到文档中的错误:

\documentclass[12pt]{book}

\usepackage{longtable}
\usepackage{booktabs}

\usepackage{makecell}
\usepackage{siunitx}    % <--- added

\begin{document}

\begin{longtable}{@{} l*{4}{S[table-format=4.0,
                              group-minimum-digits=4]}
                 @{} }
    \caption[Listed Building per category.]
            {Totals of listed buildings per category in each council from 2010.}
    \label{LBperCat}                                            \\
    \toprule
                    &   \multicolumn{3}{c}{Category}            \\
    \cmidrule(lr){2-4}
Local Authority     &   {A}  &  {B} &   {C} &   {Totals}        \\
    \midrule
\endfirsthead
    \caption[Listed Building per category.]
            {Totals of listed buildings per category in each council from 2010. (cont.)}
    \label{LBperCat}                                            \\
    \toprule
                    &   \multicolumn{3}{c}{Category}            \\
    \cmidrule(lr){2-4}
Local Authority     &   {A}  &  {B} &   {C} &   {Totals}        \\
    \midrule
\endhead
    \midrule
\multicolumn{5}{r}{\footnotesize\textit{Continued on next page}}
\endfoot
    \bottomrule
\endlastfoot
%
Aberdeen        & 68    & 679   & 464   & 1211  \\
Abredeenshire   & 208   & 1640  & 1948  & 3796  \\
Angus \& Bute   & 96    & 1019  & 1035  & 2150  \\
Argyll \& Bute  & 143   & 988   & 738   & 1869  \\
Clackmannan     & 17    & 134   & 152   & 303   \\
Comhairle Nan Eilean Siar
                & 19    & 172   & 84    & 275   \\
Dumfries \& Galloway
                & 224   & 1798  & 1382  & 3404  \\
Dundee          & 82    & 564   & 247   & 893   \\
East AYRSHIRE   & 45    & 339   & 364   & 748   \\
East Dunbartonshire
                & 16    & 89    & 75    & 180   \\
East Lothian    & 136   & 1083  & 602   & 1821  \\
East Refrenshire
                & 5     & 93    & 37    & 135   \\
Edinburgh       & 910   & 2646  & 1290  & 4846  \\
Falkirk         & 27    & 195   & 128   & 350   \\
Fife            & 212   & 2198  & 2549  & 4959  \\
Glasgow         & 281   & 1273  & 286   & 1840  \\
Highland        & 186   & 1669  & 1161  & 3016  \\
Inverclyde      & 25    & 129   & 91    & 245   \\
\makecell[l]{Loch Lomond \&\\
             Trossachs National Park}
                & 27    & 208   & 335   & 570   \\
Midlothian      & 71    & 315   & 327   & 713   \\
Moray           & 117   & 768   & 785   & 1670  \\
North Ayrshire  & 41    & 406   & 391   & 838   \\
North Lanarkshire
                & 10    & 147   & 155   & 312   \\
Orkney Islands  & 24    & 295   & 313   & 632   \\
Perth \& Kincorss
                & 160   & 1438  & 1500  & 3098  \\
Renfrewshire    & 39    & 343   & 185   & 567   \\
Scottish Borders
                & 182   & 1247  & 1560  & 2989  \\
Shetland        & 13    & 173   & 158   & 344   \\
South Ayrshrie  & 74    & 438   & 429   & 941   \\
South Lanarkshire & 92  & 544   & 443   & 1079  \\
Stirling        & 80    & 561   & 530   & 1171  \\
West Dunbartonshire
                & 16    & 83    & 39    & 138   \\
West Lothian    & 43    & 215   & 179   & 437   \\
Totals          & 3689  & 23889 & 19962 & 47540 \\
\end{longtable}
\end{document}

相关内容