longtable+ltxtable = ! 额外的对齐制表符已更改为 \cr

longtable+ltxtable = ! 额外的对齐制表符已更改为 \cr

如何修复?

我丢失了任何 & 或换行符?

错误:

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

l.16            h1 &
         h2 & h3 \\

代码:

\documentclass[a4paper,12pt]{article}
\usepackage[]{booktabs}         % to improve tables
\usepackage{tabularx}           % to add width in tables
\usepackage{ltxtable}           % to mixing tabularx + longtable
\usepackage{longtable}          % to permit big tables over pages
\usepackage{multirow}           % to set multirows in tables

\begin{document}
    \begin{longtable}{cXX}
        \label{tab:qualityCriteria} \\
    \caption{Criteria to qualify.} \\
    \toprule

        h1 & h2 & h3 \\

    \midrule
    \endhead

        c1 & c2 & c3 \\

        c4 & c5 & c6 \\

    \bottomrule

\end{longtable}
\end{document}

答案1

我不明白ltxtable和发生了什么longtable,但我建议加载ltablex似乎具有相同功能(将功能扩展longtabletabularx)并允许您的代码工作:

\documentclass[a4paper,12pt]{article}
\usepackage{booktabs} % to improve tables
\usepackage{ltablex} % to mixing tabularx + longtable
\usepackage{multirow} % to set multirows in tables

\begin{document}

\begin{table}[!htp]\keepXColumns
  \begin{tabularx}{0.5\linewidth}{cXX}
    \label{tab:qualityCriteria} \\
    \caption{Criteria to qualify.} \\
    \toprule
    h1 & h2 & h3 \\
    \midrule
    \endhead
    c1 & c2 & c3 \\
    c4 & c5 & c6 \\
    \bottomrule
  \end{tabularx}
\end{table}

\end{document}

在此处输入图片描述

相关内容