[Tex/LaTex] Longtable: Illegal pream-token (\caption)

longtable

there is a table in my document that need to span over 2 pages. The compilation of the code gives me the following error message:

Error message ! Package array Error: Illegal pream-token
(\caption): `c' used.

See the array package documentation for explanation. Type H
for immediate help. …
l.513 \caption
[Comparaison …

?
This is my code:

Anyone could help me to fix it? Thanks.

\documentclass[a4paper, 12pt]{report}
\usepackage{chapterbib}
\usepackage{lmodern}
\usepackage{blindtext}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{fancyhdr}
\usepackage{amsfonts}
\usepackage{url}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{color}
\usepackage{subcaption}
\usepackage{verbatim}
\usepackage{enumerate}
\usepackage{makeidx}
\usepackage{topcapt}
\usepackage{setspace}
\usepackage{rotfloat}
\usepackage{tabularx}
\usepackage{diagbox}
\usepackage{makecell}
\usepackage{pdflscape}
\usepackage{longtable}
\usepackage[square,sort,comma, authoryear]{natbib}

\makeindex

\begin{document}

    \setlength{\LTleft}{0pt}
    \begin{landscape}
        \begin{center}
            \begin{longtable}
                \caption[Comparaison]{Comparaison}
                \endfirsthead
                {{\tablename\ \thetable{} -- suite du tableau de la page précédente}} \\
                \endhead
                \hline
                \endlastfoot
                \noindent\makebox[\textwidth]
                {
                    \begin{tabular}{|p{0.13\textwidth}||p{0.40\textwidth}|p{0.40\textwidth}|p{0.08\textwidth}|p{0.08\textwidth}|p{0.07\textwidth}|p{0.08\textwidth}|p{0.08\textwidth}|p{0.08\textwidth}|p{0.08\textwidth}|}
                    \hline
                    \textbf{Attributs} & \thead{Caracté-\\ristiques}&\thead{Méthode}&\thead{Destina-\\taires}&\thead{Résulat}&\thead{}&\thead{Modu-\\larité}&\thead{Buts} & \thead{} & \thead{Docu-\\menta-\\tion}\\
                    \hline
                    \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{}\\
                    \hline
                    \textbf{Auteurs} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{}\\
                    \hline
                    \hline
                    \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{}\\
                    \hline
                    \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{}\\
                    \hline

                    \hline
                    \end{tabular}
                }
                \label{tab: comparaisonPatrons_1}
            \end{longtable}
        \end{center}
    \end{landscape}
\end{document}

Best Answer

longtable takes the same column syntax astabular, it should never be in center (the environment has no effect on it as it is full with) The horizontal with inlandscape is linewidth not \textwidth

\documentclass[a4paper, 12pt]{report}
\usepackage{chapterbib}
\usepackage{lmodern}
\usepackage{blindtext}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{fancyhdr}
\usepackage{amsfonts}
\usepackage{url}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{color}
\usepackage{subcaption}
\usepackage{verbatim}
\usepackage{enumerate}
\usepackage{makeidx}
\usepackage{topcapt}
\usepackage{setspace}
\usepackage{rotfloat}
\usepackage{tabularx}
\usepackage{diagbox}
\usepackage{makecell}
\usepackage{pdflscape}
\usepackage{longtable}
\usepackage[square,sort,comma, authoryear]{natbib}

\makeindex

\begin{document}

    \begin{landscape}



            \begin{longtable}{|p{0.13\linewidth}||p{0.10\linewidth}|p{0.1\linewidth}|p{0.06\linewidth}|p{0.06\linewidth}|p{0.07\linewidth}|p{0.06\linewidth}|p{0.06\linewidth}|p{0.06\linewidth}|p{0.06\linewidth}|}
                \caption{Comparaison\label{tab: comparaisonPatrons_1}}
                \endfirsthead
                \caption[]{suite du tableau de la page précédente} \\
                \endhead
                \hline
                \endlastfoot
                    \hline
                    \textbf{Attributs} & \thead{Caracté-\\ristiques}&\thead{Méthode}&\thead{Destina-\\taires}&\thead{Résulat}&\thead{}&\thead{Modu-\\larité}&\thead{Buts} & \thead{} & \thead{Docu-\\menta-\\tion}\\
                    \hline
                    \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{}\\
                    \hline
                    \textbf{Auteurs} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{}\\
                    \hline
                    \hline
                    \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{}\\
                    \hline
                    \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{} & \footnotesize{}\\
                    \hline
            \end{longtable}

    \end{landscape}
\end{document}