Graphics, Figures & TablesMispaced \noalign in longtable

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
xana
Posts: 14
Joined: Mon May 31, 2010 5:31 am

Mispaced \noalign in longtable

Post by xana »

Hello everybody,

I have a longtable with \centering in a latex document and it appears always the same error:

! Misplaced \noalign.
\hline ->\noalign
{\ifnum 0=`}\fi \penalty \@M \futurelet \@let@token \LT@@h
l.680 \hline

Well, I already done some research and I know that this error is common in longtables.

Thus, I already substituted all the \\ in the longtable for \tabularnewline.

And the error remains. I don't know what else to do. Can somebody please give me some suggestions?

Thank you. Best regards

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Mispaced \noalign in longtable

Post by gmedina »

Hi,

please post a reduced, minimal version of your code (in the sense of a minimal working example) allowing us to reproduce the error.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
xana
Posts: 14
Joined: Mon May 31, 2010 5:31 am

Mispaced \noalign in longtable

Post by xana »

Hi. This is an example of the code of my longtable:

Code: Select all

\begin{center}
\footnotesize
\setlongtables
\renewcommand{\arraystretch}{1.5}
\renewcommand{\multirowsetup}{\centering}
\centering
\setlength{\tabcolsep}{2mm}
\begin{longtable}{|>{\centering}m{2.6cm}|>{\centering}m{2.5cm}|>{\centering}m{2.1cm}|>{\centering}m{3cm}|>{\centering}m{3cm}|}
\caption{Example LongTable}
\hline
\textbf{title 1} & \textbf{title 2} & \textbf{title 3} & \textbf{title 4} & \textbf{title 5} \tabularnewline
\hline
Data 1 & Data 2 & Data 3 & Data 4 & Data 5 \tabularnewline\hline
Data 1 & Data 2 & Data 3 & Data 4 & Data 5 \tabularnewline\hline
Data 1 & Data 2 & Data 3 & Data 4 & Data 5 \tabularnewline\hline
\end{longtable}
\label{tab:TabResumo}
\end{center}
Instead of \tabularnewline I had first \\, but with both the same error appears:

! Misplaced \noalign.
\hline ->\noalign
{\ifnum 0=`}\fi \penalty \@M \futurelet \@let@token \LT@@h
l.680 \hline

And suggestions are welcome.

Best regards.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Mispaced \noalign in longtable

Post by gmedina »

Please, next time post complete, minimal and compilable code and not just snippets. In a longtable environment You must place a line change command \\ (or \tabularnewline) after the \caption command:

Code: Select all

...
\caption{Example LongTable} \tabularnewline
...
1,1,2,3,5,8,13,21,34,55,89,144,233,...
xana
Posts: 14
Joined: Mon May 31, 2010 5:31 am

Mispaced \noalign in longtable

Post by xana »

Ok. Thanks, that resolved this error.

But now I'm having another error. Hope this time that I posted the code right.

I'm having the error:
Missing { inserted
realted to the first row of the longtable with a raisebox.

Code: Select all

\begin{document}
\begin{center}
\footnotesize
\setlongtables
\renewcommand{\arraystretch}{1.5}
\renewcommand{\multirowsetup}{\centering}
\centering
\setlength{\tabcolsep}{2mm}
\begin{longtable}{|>{\centering}m{2.6cm}|>{\centering}m{2cm}|>{\centering}m{2.6cm}|>{\centering}m{2.2cm}|>{\centering}m{1.6cm}|>{\centering}m{1.8cm}|}
\caption{Example LongTable}
\tabularnewline\hline
\textbf{title 1} & \textbf{title 2} & \textbf{title 3} & \textbf{title 4} & \textbf{title 5} & \textbf{title 6}
\endfirsthead
\multicolumn{6}{c}%
{{\bfseries \tablename\ \thetable{} -- Continuation from previous page}} \tabularnewline\hline
\textbf{title 1} & \textbf{title 2} & \textbf{title 3} & \textbf{title 4} & \textbf{title 5} & \textbf{title 6}
\tabularnewline
\endhead
\hline 
\multicolumn{6}{|r|}{{Continue in next page}} \tabularnewline\hline
\endfoot
\endlastfoot
\multirow{3}{2.6cm}{Data 1} & \multirow{3}{2cm}{Data 2} & Data 3 & Data 4 & Data 5 & \raisebox{-1.6ex}{D}\tabularnewline\cline{4-7}
&& Data 3 & Data 4 & Data 5 & \raisebox{-1.6ex}{D}\tabularnewline\cline{4-7}
&& Data 3 & Data 4 & Data 5 & D \tabularnewline\hline                
\end{longtable}
\label{tab:TabResumo}
\end{center}
\end{document}
I need the raisebox to align the text with the rest of the text from the same row.

Hope someone understand my doubt and can help me.

Best regards
xana
Posts: 14
Joined: Mon May 31, 2010 5:31 am

Re: Mispaced \noalign in longtable

Post by xana »

Ok. I already discovered my error. I had a extra } in the line.

Sorry that I bothered you with this subject.

But now in the same line that I told you before, I have this error:

! Extra alignment tab has been changed to \cr.
<template> \endtemplate

Can somebody help me solve this problem. Thanks a lot all the help.

Best regards
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Mispaced \noalign in longtable

Post by gmedina »

You declared six columns for your table so you cannot use

Code: Select all

\cline{4-7}
use

Code: Select all

\cline{4-6}
instead.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
xana
Posts: 14
Joined: Mon May 31, 2010 5:31 am

Re: Mispaced \noalign in longtable

Post by xana »

Hi. Thank you so much. That resolved my problem. ;)

In the image I attached, you can see part of the longtable I have.
My problem is that in the last column the title and some letters appeared higher or lower than the rest of the text from the longtable.

I know that if I have only one letter I can use \raisebox to align the text, but what should I use in a whole word to achieve the alignment?

Best regards
Attachments
Untitled.png
Untitled.png (42.35 KiB) Viewed 24632 times
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Mispaced \noalign in longtable

Post by gmedina »

I am getting tired of asking you to accompany your questions with minimal, compilable code, in other words, with a minimal working example.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply