# merging cells with tabularx

I'am writing my thesis. I want to create a table.

I'm using the tabularx environment My code:

\begin{table}[htbp]
\centering
\begin{tabularx}{\textwidth}{*{3}{>{\centering\arraybackslash}X}}
\toprule
\cmidrule{2-3}
& Carga Mineral (\%) \\
& 20    & 30 \\
\midrule
Fibra & 1,266 & 252 \\
GCC & 0,316 & 52 \\
Amido & 0,016 & 25 \\
ASA & 0,002 & 252 \\
Percol & 0,00032 & 25 \\
\bottomrule
\end{tabularx}
\label{tab_formacao_folhas}%
\end{table}%ckquote


But I want merging the text "Quantidade (g)" and "Carga Mineral" in second and third column. With tabularx , I can't use multicolumn.

• just use \multicolumn{2}{c}{Quantidade (g} May 31 '14 at 23:20
• I wouldn't use tabularx for this in an any case, numeric columns would look better using dcolumn or siunitx so that the digits were aligned May 31 '14 at 23:22
• Can you give me a exemple of dcolumn or siunitx ? May 31 '14 at 23:33
• @user46548 Please see mirrors.ctan.org/macros/latex/required/tools/dcolumn.pdf pp 1-2, and mirrors.ctan.org/macros/latex/contrib/siunitx/siunitx.pdf. There should be plenty more examples over the Internet. May 31 '14 at 23:38
• You can use tabularx if you want but your comment that that means that you can not use \multicolumn is wrong. But please always post a complete document not just a fragment. (I would not use tabularx for this (even though I wrote that package) it is just three numeric columns so forcing the table to page width just makes it harder to read Jun 1 '14 at 0:42

The comment about not being able to use \multicolumn with tabularx is wrong as shown in the first table below, but tabularx is really for adjusting the widths of paragraphs in p columns. Using it for numeric columns doesn't really produce a good result, it just spaces the table out, making it harder to read, and if you use \centering the numeric data isn't aligned. I'd use a setting more like the second table where the data aligns on the ,

\documentclass{article}

\usepackage{dcolumn,tabularx,booktabs}

\begin{document}

\begin{table}[htbp]
%  \centering does nothing if table is full width
\begin{tabularx}{\textwidth}{*{3}{>{\centering\arraybackslash}X}}
\toprule
\cmidrule{2-3}
& \multicolumn{2}{c}{Carga Mineral (\%)} \\
& 20    & 30 \\
\midrule
Fibra & 1,266 & 252 \\
GCC & 0,316 & 52 \\
Amido & 0,016 & 25 \\
ASA & 0,002 & 252 \\
Percol & 0,00032 & 25 \\
\bottomrule
\end{tabularx}
\label{tab_formacao_folhas}%
\end{table}
\begin{table}[htbp]
\centering
\begin{tabular}{cD{,}{,}{3.7}D{,}{,}{5.1}}
\toprule
\cmidrule{2-3}
& \multicolumn{2}{c}{Carga Mineral (\%)} \\
& \multicolumn{1}{c}{20}    &  \multicolumn{1}{c}{30} \\
\midrule
Fibra & 1,266 & 252 \\
GCC & 0,316 & 52 \\
Amido & 0,016 & 25 \\
ASA & 0,002 & 252 \\
Percol & 0,00032 & 25 \\
\bottomrule
\end{tabular}
\label{tab_formacao_folhas2}%
\end{table}

\end{document}