Der zusätzliche Ausrichtungstab wurde in \cr geändert. } using table, tabular und resizebox

Der zusätzliche Ausrichtungstab wurde in \cr geändert. } using table, tabular und resizebox

Ich habe alle anderen Threads zu diesem Thema durchgesehen und bin nicht dahinter gekommen. Es muss etwas sein, das ich überhaupt nicht verstehe.

Ich habe die obige Fehlermeldung erhalten: „Zusätzliche Ausrichtungsregisterkarte wurde in \cr geändert. }“

Hier ist ein vollständig reproduzierbarer Codeausschnitt

\begin{table}[h!]
    \resizebox{5in}{!}{
        \begin{tabular}[h!]{|c||c|c|c|||c|c|c|}
            \hline
            \multicolumn{}{|c||}{Dataset} &
            \multicolumn{3}{c|||}{A} &
            \multicolumn{3}{c|}{B} &  
            \hline


            \bfseries Year & \bfseries parameter & \bfseries gof & \bfseries p-value & \bfseries parameter & \bfseries gof & \bfseries p-value \\
            \hline


1998 & 1.2661         & 0.4046   & 0.57         & 1.2889            & 0.3214      & 0.7             \\ \hline
1999 & 1.2685         & 0.4049   & 0.58         & 1.2913            & 0.3225      & 0.71            \\ \hline
2000 & 1.2681         & 0.4053   & 0.57         & 1.2942            & 0.321       & 0.71            \\ \hline
2001 & 1.2679         & 0.4082   & 0.56         & 1.2896            & 0.3208      & 0.71            \\ \hline
2002 & 1.2666         & 0.4098   & 0.55         & 1.2907            & 0.321       & 0.71            \\ \hline
2003 & 1.2673         & 0.4096   & 0.55         & 1.2849            & 0.3203      & 0.71            \\ \hline
2004 & 1.2678         & 0.409    & 0.57         & 1.2866            & 0.3187      & 0.72            \\ \hline

        \end{tabular}
    }
    \caption[stuff]{morestuff}
    \label{table:all.models}
\end{table}

Kann jemand etwas sehen, was ich nicht sehe?

Vielen Dank im Voraus!

Antwort1

Die unmittelbare Quelle der Fehlermeldung ist die Zeile

\multicolumn{3}{c|}{B} &

Es sollte sein

\multicolumn{3}{c|}{B} \\

Zwei zusätzliche Beobachtungen:

  • \multicolumn{}{|c||}{Dataset}ist auch nicht richtig. Es müsste entweder \multicolumn{1}{|c||}{Dataset}oder heißen, viel einfacher, Dataset.

  • Die Option [h!]in \begin{tabular}[h!]ist bedeutungslos und wird einfach ignoriert. Gültige Optionen sind t(„top“), c(„center“ – die Standardeinstellung) und b(„bottom“).


Nachtrag: Wenn dies so wäreMeinTabelle, ich würde mich sehr bemühen, ihr ein viel offeneres "Aussehen" zu verleihen, hauptsächlich indem ich alle vertikalen Linien weglasse und weniger, aber gut verteilte horizontale Linien verwende. Der \resizebox"Vorschlaghammer" ist nicht nötig. Verwenden Sie tabular*stattdessen eine Umgebung. Ich würde auch nichtFettdruckdie Überschriftenzellen, und ich würde dem Überschriftenmaterial der Tabelle mehr Struktur verleihen und die Zahlen in den numerischen Spalten an ihren jeweiligen Dezimaltrennzeichen ausrichten.

Diese Ideen werden in der zweiten Tabelle unten umgesetzt.

Bildbeschreibung hier eingeben

\documentclass{article}
\usepackage{graphicx}

\usepackage{booktabs,siunitx}
\begin{document}
\begin{table}[h!]
\resizebox{5in}{!}{%
\begin{tabular}[h!]{|c||c|c|c||c|c|c|}
\hline
Dataset &
\multicolumn{3}{c||}{A} &
\multicolumn{3}{c|}{B} \\  
\hline
\bfseries Year & \bfseries parameter & 
\bfseries gof & \bfseries p-value & 
\bfseries parameter & \bfseries gof & 
\bfseries p-value \\
\hline
1998 & 1.2661 & 0.4046 & 0.57 & 1.2889 & 0.3214 & 0.7  \\ \hline
1999 & 1.2685 & 0.4049 & 0.58 & 1.2913 & 0.3225 & 0.71 \\ \hline
2000 & 1.2681 & 0.4053 & 0.57 & 1.2942 & 0.321  & 0.71 \\ \hline
2001 & 1.2679 & 0.4082 & 0.56 & 1.2896 & 0.3208 & 0.71 \\ \hline
2002 & 1.2666 & 0.4098 & 0.55 & 1.2907 & 0.321  & 0.71 \\ \hline
2003 & 1.2673 & 0.4096 & 0.55 & 1.2849 & 0.3203 & 0.71 \\ \hline
2004 & 1.2678 & 0.409  & 0.57 & 1.2866 & 0.3187 & 0.72 \\ \hline
\end{tabular}
}% end of scope of \resizebox instruction
\caption[stuff]{morestuff}
\label{table:all.models}
\end{table}

\begin{table}[h!]
\setlength\tabcolsep{0pt}
\begin{tabular*}{5in}{@{\extracolsep{\fill}} l 
    *{2}{*{2}{S[table-format=1.4]}S[table-format=1.2]} }
\toprule
Year & \multicolumn{6}{c}{Dataset} \\
\cmidrule{2-7}
& \multicolumn{3}{c}{A} & \multicolumn{3}{c}{B} \\  
\cmidrule{2-4} \cmidrule{5-7}
& {Parameter} & {gof} & {p-value} & {Parameter} & {gof} & {p-value} \\
\midrule
1998 & 1.2661 & 0.4046 & 0.57 & 1.2889 & 0.3214 & 0.7  \\ 
1999 & 1.2685 & 0.4049 & 0.58 & 1.2913 & 0.3225 & 0.71 \\ 
2000 & 1.2681 & 0.4053 & 0.57 & 1.2942 & 0.321  & 0.71 \\ 
2001 & 1.2679 & 0.4082 & 0.56 & 1.2896 & 0.3208 & 0.71 \\ 
2002 & 1.2666 & 0.4098 & 0.55 & 1.2907 & 0.321  & 0.71 \\ 
2003 & 1.2673 & 0.4096 & 0.55 & 1.2849 & 0.3203 & 0.71 \\ 
2004 & 1.2678 & 0.409  & 0.57 & 1.2866 & 0.3187 & 0.72 \\ \bottomrule
\end{tabular*}
\caption{A much more ``open'' look}
\label{table:another_look}
\end{table}
\end{document}

Antwort2

Off-Topic:

Ich würde Ihren Tisch folgendermaßen gestalten:

Bildbeschreibung hier eingeben

(rote Linien zeigen Textränder an)

\documentclass{article}
\usepackage{booktabs, % for nicer horizontal rules (\toprule, \cmidrule, \midrule,\bottomrule)
            makecell} % for column headers (\thesd)
\renewcommand\theadfont{\bfseries\small}
\renewcommand\theadgape{}
\usepackage{siunitx}  % for S column type: numbers are aligned at decimal points

\begin{document}
    \begin{table}[h!]
    \setlength\tabcolsep{0pt}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
                         c
                    *{2}{S[table-format=1.4]}
                         S[table-format=1.2]
                    *{2}{S[table-format=1.4]}
                         S[table-format=1.2]
                            }
    \toprule
Dataset & \multicolumn{3}{c}{A} & \multicolumn{3}{c}{B}     \\
    \cmidrule{2-4}\cmidrule{5-7}
\thead{Year}    & {\thead{parameter}} & {\thead{gof}} & {\thead{p-value}}
                & {\thead{parameter}} & {\thead{gof}} & {\thead{p-value}} \\
    \midrule
1998 & 1.2661   & 0.4046   & 0.57   & 1.2889    & 0.3214    & 0.7   \\
1999 & 1.2685   & 0.4049   & 0.58   & 1.2913    & 0.3225    & 0.71  \\
2000 & 1.2681   & 0.4053   & 0.57   & 1.2942    & 0.321     & 0.71  \\
2001 & 1.2679   & 0.4082   & 0.56   & 1.2896    & 0.3208    & 0.71  \\
2002 & 1.2666   & 0.4098   & 0.55   & 1.2907    & 0.321     & 0.71  \\
2003 & 1.2673   & 0.4096   & 0.55   & 1.2849    & 0.3203    & 0.71  \\
2004 & 1.2678   & 0.409    & 0.57   & 1.2866    & 0.3187    & 0.72  \\
    \bottomrule
    \end{tabular*}
\caption[stuff]{morestuff}
\label{table:all.models}
    \end{table}
\end{document}

verwandte Informationen