0

I got a longtable for my project with the caption at the bottom. Creating the table alone works perfectly fine, but as soon as I try to add a toprule it throws a ! Misplaced \noalign.\hline ->\noalign{\ifnum 0=`}\fi \penalty \@M \futurelet \@let@token \LT@@h... \hline error. In this case I added a toprule with the \hline command, but same happens when I use booktabs and \toprule.

Here's a MWE:

\documentclass[pdftex,a4paper,parskip=half, 11pt]{scrartcl}
\usepackage[center]{caption}
\usepackage{longtable}
\usepackage{lipsum}

\begin{document}
\begin{longtable}{ |p{90mm} | p{30mm}|}[h] 
    %\hline %uncomment this hline to produce error  
    \textbf{Kommentar} & \textbf{Versuchsgruppe (Gesicht)} \\
    \hline
    \lipsum[1-1] & animiert \\
    \hline
    \lipsum[2-2] & abstrakt \\
    \hline
    \lipsum[3-3] & abstrakt \\
    \hline
    \lipsum[4-4] & abstrakt \\
    \hline
    \lipsum[5-5] & echt \\
    \hline
    \caption{Die in der qualitativen Analyse betrachteten Kommentare (formatiert)} \\
\end{longtable}
\end{document}

How can I solve this? All other tables in my document have a line at the top, but they don't use longtable. I really need this line for consistency. I saw that some people struggled with that due to \nopagebreak or additional line space, but my table has neither of such.

EDIT: As suggested in the comments I removed \centering, but the error still exists. It is not the only issue.

5
  • 1
    remove \centering it is doing nothing useful and generating the error Commented May 25, 2022 at 8:40
  • Remove that [h], longtable does not support an option in that location, additionally \centering inside longtable does nothing
    – daleif
    Commented May 25, 2022 at 8:41
  • You would also get the same error in tabular if you use \centering before \hline there is nothing longtable specific here. Commented May 25, 2022 at 8:42
  • @daleif You are right, [h] triggered the issue. :) You want to post the answer or should I just do it? :) Commented May 25, 2022 at 8:52
  • It is both, you're not allowed to have anything before a \hline
    – daleif
    Commented May 25, 2022 at 8:53

1 Answer 1

0

There are two errors here

  1. \begin{longtable}{ |p{90mm} | p{30mm}|}[h] should loose the [h]
  2. The original question started the longtable contents with a \centering which would not do much, but is nonetheless not allowed just before a \hline.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .