2

I have copy-pasted a long table from a colleague's document (with permission) to help me create a long table. When trying to compile the compilation stops at \end{longtabu} and if I inactivate both \begin{longtabu} and \end{longtabu} the \end{landscape}appears to be the problem instead. Inactivating {landscape} creates a new problem. What am I doing wrong?

\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} 

Edit: This is the full preamble of the borrowed 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}
Mico
  • 506,678
  • the first error is ! Undefined control sequence. <recently read> \toprule as you haven't loaded booktabs the second error is ! Undefined control sequence. <inserted text> ...s}\\ \toprule Paper\footnotemk as you haven't loaded whatever package defines \footnotemk (I can't guess) – David Carlisle Mar 31 '15 at 10:55
  • Thank you David. When I load the usepackage booktabs I do get rid of the first error. I do have a usepackage called {tablefootnote} and thought it could administrate the footnotes. I am new to LaTeX so I need to be sure I understand it correctly: Your suggestion is to find a usepackage that can handle footnotes and load it - and the problem will be solved? – Katarina Mar 31 '15 at 11:02
  • It's using a command \footnotemk that is not defined. The person you got the code from must have defined it in their document or loaded a package that defines it. It's not a command I recognise so can't really help. \newcommand\footnotemk[1]{\textsuperscript{#1}} might be enough, It will make the error go away at least but that is just a guess of the intention. – David Carlisle Mar 31 '15 at 11:12
  • Thank you again. I will look at the full preamble (correct term?) of the document I borrowed. I might have to ask again, though. I added the full preamble as an edit to my original question. It looks messy though. Sorry for that. – Katarina Mar 31 '15 at 11:17
  • there you go, look at the bottom two lines, it was a local definition in that document \newcommand{\footnotemk}[1]{$^{\text{#1}}$} \newcommand{\footnotetxt}[2]{\footnotemk{#1} #2\par} just copy those – David Carlisle Mar 31 '15 at 13:09
  • Hi and welcome, crosspost to LaTeX-community. – Johannes_B Mar 31 '15 at 13:34

1 Answers1

2

Once you have copied all the needed definitions, it mostly works, one use of \midrule generates an error, not sure why looks like some tabu weirdness. I commented it out here but you could use \hline or something, or perhaps in the context of teh full document it works..

\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}
David Carlisle
  • 757,742