I have a problem which seems to be common, but the solutions suggested to this question don not work for me.
So to start with, this is the relevant extract of my preamble:
\documentclass[a4paper,12pt,twoside,openright, english]{book}
\usepackage{latexsym, syntonly, textcomp, amsmath, caption, float}
\usepackage[nottoc,notlot,notlof]{tocbibind}
\usepackage{graphicx}
\usepackage[figuresright]{rotating}
\usepackage{natbib, longtable}
\usepackage{babel}
\usepackage{bm}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{threeparttable}
\usepackage{array}
Now, the original table that I had, which produced the ! Package array Error: Illegal pream-token (\centering):
c' used.`, looked like this:
\begin{center}
\begin{longtable}[htbp]
\caption[short caption]]{And the long one.}
\begin{tabular}{ r c c c l }
\hline
\textbf{A} & \textbf{b} & \textbf{c} & \textbf{d} & \textbf{date} \\
\hline
1 & 113.4203 & 0.066389 & 3.49937 & 29/05/2017 \\
2 & 113.4872 & 0.07142 & 3.509623 & 31/05/2017 \\
2 & 112.5789 & 0.068867 & 3.73738 & 30/09/2017 \\
3 & 113.2167 & 0.072829 & 3.443203 & 2/12/2017 \\
4 & 112.197 & 0.080533 & 3.443551 & 11/01/2017 \\
4 & 112.1471 & 0.081132 & 3.60491 & 12/01/2017 \\
4 & 112.421 & 0.088665 & 3.580358 & 28/01/2017 \\
5 & 111.5894 & 0.089705 & 3.519745 & 12/02/2017 \\
6 & 111.6953 & 0.089302 & 3.51827 & 13/02/2017 \\
\hline
\end{tabular}%
\label{tab:mytab}%
\end{longtable}%
\end{center}
But after reading the other questions, I though I "fixed" it, when I removed the tabular
, center
and moved the aligning commands {rccc}
to the longtable
, as shown below:
%\begin{center}
\begin{longtable}{ r c c c l }%[htbp]
\caption[short caption]]{And the long one.}
%\begin{tabular}
\hline
\textbf{A} & \textbf{b} & \textbf{c} & \textbf{d} & \textbf{date} \\
\hline
1 & 113.4203 & 0.066389 & 3.49937 & 29/05/2017 \\
2 & 113.4872 & 0.07142 & 3.509623 & 31/05/2017 \\
2 & 112.5789 & 0.068867 & 3.73738 & 30/09/2017 \\
3 & 113.2167 & 0.072829 & 3.443203 & 2/12/2017 \\
4 & 112.197 & 0.080533 & 3.443551 & 11/01/2017 \\
4 & 112.1471 & 0.081132 & 3.60491 & 12/01/2017 \\
4 & 112.421 & 0.088665 & 3.580358 & 28/01/2017 \\
5 & 111.5894 & 0.089705 & 3.519745 & 12/02/2017 \\
6 & 111.6953 & 0.089302 & 3.51827 & 13/02/2017 \\
\hline
%\end{tabular}%
\label{tab:mytab}%
\end{longtable}%
%\end{center}
This produced three errors!
! Misplaced \noalign.
\hline ->\noalign
{\ifnum 0=`}\fi \penalty \@M \futurelet \@let@token \LT@@h...
l.126 \hline
I expect to see \noalign only after the \cr of
an alignment. Proceed, and I'll ignore this case.
! Misplaced \omit.
\multispan ->\omit
\@multispan
l.127 \textbf
{A} & \textbf{b} & \textbf{c} & \textbf{d} & \tex...
I expect to see \omit only after tab marks or the \cr of
an alignment. Proceed, and I'll ignore this case.
! Extra alignment tab has been changed to \cr.
<template> \endtemplate
l.127 \textbf
{A} & \textbf{b} & \textbf{c} & \textbf{d} & \tex...
You have given more \span or & marks than there were
in the preamble to the \halign or \valign now in progress.
So I'll assume that you meant to type \cr instead.
How can I make it work?
]
as part of your\caption
...