I am trying to define the maximum width of a tabular column, see the code below:
\documentclass{article}
\usepackage[]{float}
\usepackage[]{hyperref}
\usepackage[]{booktabs}
\usepackage[]{array}
\usepackage[]{varwidth}
\title{}
\author{}
\date{\today}
\newcolumntype{\vbf}{>{\begin{varwidth}{3.0cm}}l<{\end{varwidth}}}
\begin{document}
\begin{table}[H]
\centering
\begin{tabular}{\vbf\vbf\vbf\vbf\vbf\vbf}
\toprule
0 & 1 & 2 & 3 & 4 & 5 \\
\midrule
1 & 11802316.16 & 10270230.14 & 210947.01 & 6716332.35 & 6808728.66 \\
2 & 9992538.31 & 10211855.55 & 331381.44 & 6444971.54 & 6403637.45 \\
3 & 9989460.45 & 10174367.75 & 282403.66 & 7065539.95 & 7152965.85 \\
4 & 11773342.70 & 10413039.41 & 297383.17 & 6267637.00 & 6375493.07 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
The error is:
! Misplaced \noalign.
\midrule ^^@-\noalign
{\ifnum 0=`}\fi \@aboverulesep =\aboverulesep \global \@...
l.21 \midrule
How can I fix this error?
varwidth
? From your MWE I can conclude, that you actually needS
column type from packagesiunitx
.\begin{varwidth}{3cm}7121855.55\end{varwidth}
there is nothing happening IMO. What do you try to get here?