[Tex/LaTex] \endhead in tabulary: “Undefined control sequence. \end{tabulary}”

errorstablestabulary

I am using the packages tabulary, booktabs and longtable. However when using \endhead I get the stated error.

\begin{tabulary}{\linewidth}{RRRR}
\toprule
$U$ [kV] & $\lambda$ [$10^{-11}\,$m] & $\theta$ [$^\circ$] & $d$ [$10^{-11}\,$m]\\\midule\midrule
\endhead
1 & 2 & 3 & 4\\
\end{tabulary}

Best Answer

You misquote the error message in your title. It is not \end{tabulary} that is undefined.

The first two errors in your document are

! Undefined control sequence.
<recently read> \midule 

l.11 \end{tabulary}

? 
! Undefined control sequence.
\LT@echunk ->\crcr \LT@save@row 
                                \cr \egroup \global \setbox \@ne \lastbox \u...
l.11 \end{tabulary}

So the first is a simple typo \midule is undefined and should be \midrule.

The second says that \LT@save@row is undefined, which is an internal longtable command which latex tried to execute as part of \endhead which is only defined for longtable.