3

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!

  • 4
    you declared 7 columns and your first row has 8 cells. – David Carlisle Oct 21 '15 at 8:32
  • 1
    Welcome to tex.sx (in general though please make your examples complete so people can run them. tabularx, Y, \toprule, \cmidrule are not defined by default (I can guess some pacakages you have used, but I can't guess how Y is defined (although in this case it doesn't matter, you'd get the same form c :-) – David Carlisle Oct 21 '15 at 8:35
  • thanks for help, When I use the command \multicolumn{2}{c}{\textbf{Yarn}} it counts as 2 cells? and by the way Y is defined as: \newcolumntype{Y}{>{\centering\arraybackslash}X} – Andrea Betti Oct 21 '15 at 8:39
  • yes multicolumn{2}.... spans 2 columns. – David Carlisle Oct 21 '15 at 9:14
1

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

  • thanks a lot! do you know where I can find the documentation about siunitx package? – Andrea Betti Oct 22 '15 at 4:09
  • @AndreaBetti -- You may bring up the package's user guide by typing texdoc siunitx in a command window. – Mico Oct 22 '15 at 4:31
1

I find a way that it works!

\begin{table}
\begin{center}
\begin{footnotesize} 
\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{Main Properties of wowen fabric.}
\end{footnotesize}
\end{center}
\end{table} 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.