[Tex/LaTex] Table error – Extra alignment tab has been changed to \cr

booktabserrorstabularx

Where I did wrong?

\begin{table}
\begin{center}
\begin{tabularx}{\textwidth}{YYYYYYY}
\toprule
\textbf{Style} & \multicolumn{2}{c}{\textbf{Yarn}} & & \multicolumn{2}{c}{\textbf{Count}} & \textbf{Weight} & \textbf{Thickness} \\
\cmidrule{2-3} \cmidrule{4-5}
& Warp & Fill & Ends & Picks & $[g/m^2]$ & $[mm]$\\
\midrule

Plain & TR 30S 3L & TR 30S 3L & $4.87$ & $4.87$ & 200 & $0.23$ \\

\bottomrule
\end{tabularx}
\caption{Caption}
\end{center}
\end{table}

thanks for help!

Best Answer

Here are some suggestions on how you may want to streamline your code:

  • Use left- and right-clipping of the \cmidrule lines to better;

  • there's no need to use a center environment because the width of the tabularx environment is set to \textwidth;

  • don't typeset units of measurement in math italics -- consider using the \si macro of the siunitx package instead;

  • when using a smaller-than-normal font size for a table, do also consider reducing the amount of intercolumn whitespace: for the table at hand, a combination of \small (instead of \footnotesize) and setting \tabcolsep (the parameter that governs the amount of intercolumn whitespace) to 4pt (default: 6pt) would seem to yield a more-readable table.

  • The first column may look better if you use l instead of Y as the column type.

enter image description here

\documentclass{article}

\usepackage{tabularx,booktabs}
\newcolumntype{Y}{>{\centering\arraybackslash}X}

\usepackage[per-mode=symbol]{siunitx} % for typesetting scientific units

\begin{document}

\begin{table}
\setlength\tabcolsep{4pt} % default value: 6pt
\small  % not: "\footnotesize"

\begin{tabularx}{\textwidth}{@{} l *{6}{Y} @{}}
\toprule
\textbf{Style} & \multicolumn{2}{c}{\textbf{Yarn}} &
\multicolumn{2}{c}{\textbf{Count}} & \textbf{Weight} & \textbf{Thickness} \\
\cmidrule(lr){2-3} \cmidrule(lr){4-5}
& Warp & Fill & Ends & Picks & [\si{\gram\per\meter\squared}] & [\si{\milli\meter}]\\
\midrule
Plain & TR 30S 3L & TR 30S 3L & 4.87 & 4.87 & 200 & 0.23 \\
\bottomrule
\end{tabularx}

\caption{Main Properties of wowen fabric.}
\end{table} 

\end{document}

Just for comparison, here's the look of the table that's produced by the code you presented in your answer:

enter image description here

Related Question