! 程序包数组错误:非法前缀标记(\centering):使用了“c”。使用 longtable

! 程序包数组错误:非法前缀标记(\centering):使用了“c”。使用 longtable

我遇到了一个似乎很常见的问题,但是建议的解决方案这个问题 不适合我。

首先,这是我的前言

\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}

现在原始表我所拥有的,产生了! Package array Error: Illegal pream-token (\centering):c' used.',看起来像这样:

\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}

但在阅读了其他问题后,我觉得我“固定的“当我删除tabular并将center对齐命令移动{rccc}到 时longtable,如下所示:

%\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}

这产生了三个错误!

! 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.

我怎样才能让它工作?

答案1

\textbf用进行替换\bfseries,将其放置\caption在标签之后,并\\在第一个\hline() 之前添加了一个,也许最后的修复才能解决您的问题……但其他的对我来说也似乎很有用。

\documentclass{article}
\usepackage{longtable}

\begin{document}
\begin{longtable}{ r c c c l }%[htbp]
  \caption[short caption]{And the long one.}  \label{tab:mytab}
    \\\hline
   { \bfseries A} & {\bfseries b} & {\bfseries c} & {\bfseries d} & {\bfseries 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{longtable}%
\end{document}

相关内容