![{longtabu} 无法编译](https://linux22.com/image/308523/%7Blongtabu%7D%20%E6%97%A0%E6%B3%95%E7%BC%96%E8%AF%91.png)
我从同事的文档中复制粘贴了一个长表(经许可),以帮助我创建长表。尝试编译时,编译在 处停止,\end{longtabu}
如果我同时停用两者\begin{longtabu}
,则\end{longtabu}
似乎\end{landscape}
是问题所在。停用{landscape}
会产生新问题。我做错了什么?
\documentclass[a4paper, 12pt]{article}
\usepackage{tabularx}
\usepackage[english]{babel}
%\usepackage[round,sort&compress]{natbib} % Natbib for better citations %longnamesfirst
\usepackage{pdflscape} % landscape env
\usepackage[bottom]{footmisc}% places footnotes at page bottom
\usepackage{rotating}
\usepackage{longtable}
\usepackage{tabu}
\usepackage{tablefootnote}
\usepackage{lipsum}
\usepackage{blindtext}
\usepackage{fancyref}
\renewcommand{\fancyrefdefaultformat}{plain}
\usepackage[round,colon]{natbib}
\title{yyy}
\author{xxx.}
\begin{document}
\tabcolsep=3pt % Half the width of the horizontal space between columns
\extrarowsep=3pt
\begin{landscape}
\scriptsize
\begin{longtabu} to \linewidth {
p{14em} % paper col aligned left
c % levels
p{5em} % criterion
X[2.5,l] % state var
X[1,l] % stage length
p{4em} % decisions
l % application
X[2.5,l] % misc
}
\caption{Overview over Sheer Detection Models}\\
\toprule
Paper\footnotemk{a} & Method\footnotemk{b} & Case\footnotemk{c} & Variables\footnotemk{d} & Performance\footnotemk{e} & Species\footnotemk{f} & Misc\\
\midrule
\endfirsthead
\caption{AMS-sensor-based.}\\
\toprule
Paper\footnotemk{a} & Method\footnotemk{b} & Case\footnotemk{c} & Sensor variables\footnotemk{d} & Other variables & Performance\footnotemk{e} & Species\footnotemk{f} & Misc\\
\midrule
\endhead
\midrule
(\emph{Continued on next page}) & \\
\bottomrule
\endfoot
\bottomrule
\endlastfoot
% table content
\citet{Ref165} & Moving Average, EWMA, LOESS & CM & Electric Conductivity & Milk Yield, SCC & & Dairy Cow & Three methods tested for detecting CM at two levels of SCC-threshold (100.000 cells/ml and 400.000 cells/ml).\\
\end{longtabu}
\footnotetxt{a}{Papers have been ordered in reverse order of year.}
\footnotetxt{b}{Number of levels in the MDP. If 1 then the MDP is an ordinary MDP.}
\footnotetxt{c}{$DR$ = expected discounted reward, $R$ = expected reward, $R/T$ = average reward per time unit, $R/Q$ average reward per quantity unit. Algorithm used is given in parentheses (VI = value iteration, PI = policy iteration, HPI = hierarchical policy iteration, LP = Linear programming).}
\footnotetxt{d}{State variables for each level in the process (separated with semicolon). The number of levels/classes of each state variable is given in parentheses.}
\footnotetxt{e}{Stage length at each level in the process (separated with semicolon). Maximum number of stages given in parentheses.}
\footnotetxt{f}{R = replace, K = keep, I = Inseminate, G = Grazing, Fe = Feeding intensity, Fa = Fattening.}
\footnotetxt{g}{Animal group applied to. The country from which the parameters has been estimated is given in parentheses.}
\end{landscape}
\bibliographystyle{plainnat}
%\bibliographystyle{elsarticle-harv}
%\bibliographystyle{spbasic}
\bibliography{Refbib}
\end{document}
编辑:这是借用文件的完整序言:
%% ---------------------------------------------------------------------
%% TexStudio options
% !TeX spellcheck = en_US
% !TeX encoding = utf8
%% ---------------------------------------------------------------------
\documentclass[12pt,a4paper]{article}
\usepackage{a4wide} % Smaller margins
\usepackage[utf8]{inputenc} % Support for various letters
\usepackage{mathptmx} % Use Times as roman font and in math
\usepackage[scaled=0.95]{helvet} % Use helvetica as sans serif font and scale it down to 0.95%
%\renewcommand{\familydefault}{phv} % Use sans serif as default font
\usepackage{courier} % Use courier as typewriter font
\usepackage[T1]{fontenc} % The font encoding used. Always load after the last font package.
\usepackage{graphicx} % standard LaTeX graphics tool
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage[english]{babel}
\usepackage[round,sort&compress]{natbib} % Natbib for better citations %longnamesfirst
\usepackage{pdflscape} % landscape env
%\usepackage[bottom]{footmisc}% places footnotes at page bottom
\usepackage{rotating}
\usepackage{longtable}
\usepackage{tabu}
%\usepackage{tablefootnote}
%\usepackage{lipsum}
%\usepackage{blindtext}
\usepackage{fancyref}
\renewcommand{\fancyrefdefaultformat}{plain}
%\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathtools}
\mathtoolsset{showonlyrefs} % Show only labels if make a reference to it
\usepackage[pdftex,colorlinks=false,linkcolor=blue,breaklinks=true]{hyperref}
\usepackage{listings}
\usepackage{etex}
\usepackage{xifthen}
%% ---------------------------------------------------------------------
% Redefinitions for tables
%% ---------------------------------------------------------------------
%\renewcommand{\arraystretch}{1.25} % Setting the space between rows in tables to x times normal
%\renewcommand{\tabcolsep}{4cm} % Half the width af the horizontal space between columns
%\renewcommand{\doublerulesep}{0pt} % set the space between two hline to zero so can make a line thicker
%% ---------------------------------------------------------------------
%% ---------------------------------------------------------------------
%% Makes the title, abstract and keywords left aligned
%% Authors must be separated with \\ in \author
%% ---------------------------------------------------------------------
\makeatletter
\def\@maketitle{%
\newpage
\null
\vskip 2em%
\let \footnote \thanks
{\Large\bfseries\noindent\@title\par}%
\vskip 1.5em%
{\large
\lineskip .5em%
\raggedright\@author}
\vskip 1em%
{\noindent\small\@date}%
\par
\vskip 1.5em}
\makeatother
%% Redefine abstract environment so left justified
\renewenvironment{abstract}{\noindent\textbf{Abstract:~}}{}
%% ---------------------------------------------------------------------
%% ---------------------------------------------------------------------
%% Make DOI's clickable in the pdf files
%% ---------------------------------------------------------------------
\newcommand\doi[1]{%
\begingroup
\urlstyle{rm}
\href{http://dx.doi.org/#1}{\nolinkurl{doi:#1}}
\endgroup
}
%% ---------------------------------------------------------------------
%\newcommand{\footnotemk}[1]{\raisebox{0.5em}{\scriptsize #1}}
\newcommand{\footnotemk}[1]{$^{\text{#1}}$}
\newcommand{\footnotetxt}[2]{\footnotemk{#1} #2\par}
答案1
复制完所有需要的定义后,它基本上就可以正常工作了,但使用一次\midrule
会产生错误,不知道为什么看起来像是某种禁忌怪异。我在这里注释掉了它,但您可以使用\hline
或其他东西,或者在完整文档的上下文中它可以工作。
\documentclass[a4paper, 12pt]{article}
%\usepackage{tabularx}
%\usepackage[english]{babel}
%\usepackage[round,sort&compress]{natbib} % Natbib for better citations %longnamesfirst
\usepackage{pdflscape} % landscape env
%\usepackage[bottom]{footmisc}% places footnotes at page bottom
%\usepackage{rotating}
\usepackage{longtable,booktabs}
\usepackage{tabu}
\usepackage{amsmath}
%\renewcommand{\fancyrefdefaultformat}{plain}
\usepackage[round,colon]{natbib}
\newcommand{\footnotemk}[1]{$^{\text{#1}}$}
\newcommand{\footnotetxt}[2]{\footnotemk{#1} #2\par}
\title{yyy}
\author{xxx.}
\begin{document}
\tabcolsep=3pt % Half the width of the horizontal space between columns
\extrarowsep=3pt
\begin{landscape}
\scriptsize
\begin{longtabu} to \linewidth {
p{14em} % paper col aligned left
c % levels
p{5em} % criterion
X[2.5,l] % state var
X[1,l] % stage length
p{4em} % decisions
l % application
X[2.5,l] % misc
}
\caption{Overview over Sheer Detection Models}\\
\toprule
Paper\footnotemk{a} & Method\footnotemk{b} & Case\footnotemk{c} & Variables\footnotemk{d} & Performance\footnotemk{e} & Species\footnotemk{f} & Misc\\
\midrule
\endfirsthead
\caption{AMS-sensor-based.}\\
\toprule
Paper\footnotemk{a} & Method\footnotemk{b} & Case\footnotemk{c} & Sensor variables\footnotemk{d} & Other variables & Performance\footnotemk{e} & Species\footnotemk{f} & Misc\\
\midrule
\endhead
% \midrule
(\emph{Continued on next page}) & \\
\bottomrule
\endfoot
\bottomrule
\endlastfoot
% table content
\citet{Ref165} & Moving Average, EWMA, LOESS & CM & Electric Conductivity & Milk Yield, SCC & & Dairy Cow & Three methods tested for detecting CM at two levels of SCC-threshold (100.000 cells/ml and 400.000 cells/ml).\\
\end{longtabu}
\footnotetxt{a}{Papers have been ordered in reverse order of year.}
\footnotetxt{b}{Number of levels in the MDP. If 1 then the MDP is an ordinary MDP.}
\footnotetxt{c}{$DR$ = expected discounted reward, $R$ = expected reward, $R/T$ = average reward per time unit, $R/Q$ average reward per quantity unit. Algorithm used is given in parentheses (VI = value iteration, PI = policy iteration, HPI = hierarchical policy iteration, LP = Linear programming).}
\footnotetxt{d}{State variables for each level in the process (separated with semicolon). The number of levels/classes of each state variable is given in parentheses.}
\footnotetxt{e}{Stage length at each level in the process (separated with semicolon). Maximum number of stages given in parentheses.}
\footnotetxt{f}{R = replace, K = keep, I = Inseminate, G = Grazing, Fe = Feeding intensity, Fa = Fattening.}
\footnotetxt{g}{Animal group applied to. The country from which the parameters has been estimated is given in parentheses.}
\end{landscape}
\bibliographystyle{plainnat}
%\bibliographystyle{elsarticle-harv}
%\bibliographystyle{spbasic}
\bibliography{Refbib}
\end{document}