Graphics, Figures & Tableserror when using colortbl, longtable and input

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
aidanc
Posts: 7
Joined: Wed Dec 07, 2011 7:04 pm

error when using colortbl, longtable and input

Post by aidanc »

Hi,

I get a misplaced noalign error when I try to input a longtable
which has a \rowcolor command.

The code seems to work when pasted in, instead of input,
but I need to use input as the table is automatically generated.

Any help or workaround would be greatly appreciated.

thanks
Aidan

Code: Select all

\documentclass[10.5pt, a4paper]{article}
\usepackage[table,dvipsnames]{xcolor}
\usepackage{longtable}

\begin{document}
\begin{longtable}{
r %1
r %2
} 
\caption[short]{TITLE \label{LABEL}}\\
		\input{consol.tex}
\end{longtable}
		
\end{document}

the file consol.tex contains:

Code: Select all

\rowcolor[gray]{0.5}
Norway &2010  \\

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

Re: error when using colortbl, longtable and input

Post by Stefan Kottwitz »

Hi Aidan,

this example should work. Could you please post the .log file here, as attachment? There's an "Upload attachment" link below the edit text field, when writing, for this.

Stefan
LaTeX.org admin
aidanc
Posts: 7
Joined: Wed Dec 07, 2011 7:04 pm

Re: error when using colortbl, longtable and input

Post by aidanc »

Hi Stefan,

thanks for the quick reply. Should be attached now.

cheers,
Aidan
Attachments
colortblqn.log
(6.41 KiB) Downloaded 259 times
User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

error when using colortbl, longtable and input

Post by Stefan Kottwitz »

Interesting! I guess it's because \input cannot be expanded. It works with \@@input, but we need to use \makeatletter and \makeatother then:

Code: Select all

\documentclass[10.5pt, a4paper]{article}
\usepackage[table,dvipsnames]{xcolor}
\usepackage{longtable}
\begin{document}
\makeatletter
\begin{longtable}{
r %1
r %2
}
\caption{TITLE \label{LABEL}}\\
  \@@input consol.tex
\end{longtable}
\makeatother
\end{document}
Stefan
LaTeX.org admin
aidanc
Posts: 7
Joined: Wed Dec 07, 2011 7:04 pm

Re: error when using colortbl, longtable and input

Post by aidanc »

Thanks Stefan, I'm glad you can understand it because it's a bit beyond me!

From now on I'll enclose each of my longtables in the makeatletter commands and use @@ input. I guess this might be safer than having the commands at the start and end of the doc, as from my reading it seems they can interfere with other commands.

thanks for your help!
Aidan
Post Reply