2

I created this table:

enter image description here

I use this code:

\documentclass[12pt,twoside,a4paper,openright]{report}
\usepackage{color}
\usepackage[portuguese]{babel}
\usepackage[utf8]{inputenc}
\usepackage[hidelinks]{hyperref}
\usepackage[official]{eurosym}
\usepackage[lmargin=3.0cm,rmargin=2.0cm,tmargin=2.0cm,bmargin=2.0cm, includefoot, includehead]{geometry}
\usepackage{fancyhdr}
\usepackage{graphicx}
\graphicspath{  {fig/} }
\usepackage{mathtools}
\usepackage[round]{natbib}
\usepackage{xr}
\usepackage{siunitx}
\usepackage{booktabs, multicol, multirow}
\usepackage{pdflscape}
\usepackage{emptypage}
\usepackage{epstopdf}
\usepackage{setspace}
\usepackage{nomencl}
\usepackage{tabularx}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{ragged2e}
\usepackage{tikz}
\usepackage{gensymb}
\usepackage{array}
\usepackage{tabularx}
\usepackage{dcolumn}
\usepackage{booktabs}
\usepackage{makecell}

\newcolumntype{R}{>{\raggedleft\arraybackslash}X}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\newcolumntype{C}{>{\centering\arraybackslash}X}



\newcommand{\mc}{\multicolumn} % handy shortcut macro
\newcolumntype{Z}{>{\centering\arraybackslash}X} % handy shortcut macro
\newcolumntype{d}[1]{D{.}{\cdot}{#1}} % and yet another handy shortcut macro
\newcolumntype{,}{D{,}{,}{-2}}

\setcellgapes{2pt}
\makegapedcells
\renewcommand\cellalign{lc}

\begin{document}

\begin{table}[htbp]
  \centering
  \caption{Add caption}
    \begin{tabularx}{\textwidth}{@{}cLcccccc@{}}
  \cmidrule[0.8pt]{2-6}
 & Amostra & \multicolumn{2}{c}{H60} & \multicolumn{2}{c}{H60 Modificado} \\
   \cmidrule{2-6}
  &  \textbf{Série} & 1  & 2  & 1   & 2 \\
  &  \textbf{Data de Formação} & 10/mar & 22/abr & 08/abr & 10/abr \\
  &  \textbf{Data de Medição} & 27/mar & 28/abr & 11/abr & 11/abr \\
\addlinespace
  \multirow{6}{*}{\rotatebox[origin=C]{90}{Estruturais}} & \textbf{Filler Efectivo (\%)} & 18,25 & 18,3  & 17,6  & 17,1 \\
  & \textbf{Gramagem ($g.m^{-2}$)} & 83,8  & 85,0  & 82,8  & 83,0 \\
  & \textbf{Massa Volúmica ($g.cm^{-3}$)} & 0,72  & 0,7   & 0,7   & 0,7 \\
  & \textbf{Índice de Mão ($cm^3.g^{-1}$)} & 1,40  & 1,4   & 1,5   & 1,5 \\
  & \textbf{Resistência ao ar Gurley 100ml (s)} & 3,8   & 5,3   & 4,1   & 3,4 \\
  & \textbf{Rugosidade  ar Bendtsen, FL ($ml.min^{-1}$)} & 192   & 199,8 & 414,1 & 410,2 \\
\addlinespace
\multirow{6}{*}{\rotatebox[origin=C]{90}{Mecânicas}} & \textbf{Índice de Rebentamento ($kPa.m^2.g^{-1}$)} & 1,76  & 2,1   & 2,3   & 2,3 \\
  &  \textbf{Índice de Tracção ($N.m.g^{-1}$)} & 34,6  & 37,2  & 42,5  & 43,4 \\
  &  \textbf{Extensão (\%)} & 2,9   & 2,7   & 2,8   & 2,6 \\
  &  \textbf{Tensile Stiffness ($kN.m^{-1}$)} & 535  & 521,7 & 593,7 & 609,6 \\
  &  \textbf{Índice T.E.A. ($J.g^{-1}$)} & 0,7   & 0,7   & 0,9   & 0,8 \\
  &  \textbf{Índice de Rasgamento ($mN.m^2.g^{-1})$} & 5,6   & 5,7   & 5,7   & 5,5 \\
\addlinespace
\multirow{3}{*}{\rotatebox[origin=C]{90}{Ópticas}} &   \textbf{C.E.D.L. ($m^2.kg^{-1})$} & 48,5  & 47,6  & 43,4  & 43,7 \\
  &  \textbf{Opacidade (\%)} & 88,1  & 88,1  & 86,2  & 85,9 \\
  &  \textbf{Brancura R457 (\%)} & 84,6  & 84,9  & 84,6  & 85,8 \\
    \cmidrule[0.8pt]{2-6}
    \end{tabularx}%
  \label{tab:addlabel}%
\end{table}%

But, I want to center the numbers (in columns) with commas. How I can do it ?

5

You can achieve what you want using either the dcolumn or siunitx packages, both of which you load. Cleaning up the markup, fixing your units (which should not be italic, so could be done using \mathrm but easier using the siunitx command \si) and adding in alignment using just siunitx gives:

\documentclass{article}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage{multirow}

\usepackage[portuguese]{babel}
\usepackage[utf8]{inputenc}

\usepackage{siunitx}
\sisetup{locale = FR} % No Portuguese locale built-in, but French I think covers it

\begin{document}

\begin{table}[htbp]
  \centering
  \caption{Add caption}
  \sisetup{table-format = {3,1}}
    \begin{tabular}{@{}ll*6{S}@{}}
  \cmidrule[0.8pt]{2-6}
 & Amostra & \multicolumn{2}{c}{H60} & \multicolumn{2}{c}{H60 Modificado} \\
   \cmidrule{2-6}
  &  \textbf{Série} & {1}  & {2}  &  {1}   & {2} \\
  &  \textbf{Data de Formação} & {10/mar} & {22/abr} & {08/abr} & {10/abr} \\
  &  \textbf{Data de Medição} & {27/mar} & {28/abr} & {11/abr} & {11/abr} \\
\addlinespace
  \multirow{6}{*}{\rotatebox[origin=C]{90}{Estruturais}} & \textbf{Filler Efectivo (\%)} & 18,25 & 18,3  & 17,6  & 17,1 \\
  & \textbf{Gramagem (\si{g.m^{-2}})} & 83,8  & 85,0  & 82,8  & 83,0 \\
  & \textbf{Massa Volúmica (\si{g.cm^{-3}})} & 0,72  & 0,7   & 0,7   & 0,7 \\
  & \textbf{Índice de Mão (\si{cm^3.g^{-1}})} & 1,40  & 1,4   & 1,5   & 1,5 \\
  & \textbf{Resistência ao ar Gurley \SI{100}{ml} (\si{s})} & 3,8   & 5,3   & 4,1   & 3,4 \\
  & \textbf{Rugosidade  ar Bendtsen, FL (\si{ml.min^{-1}})} & 192   & 199,8 & 414,1 & 410,2 \\
\addlinespace
\multirow{6}{*}{\rotatebox[origin=C]{90}{Mecânicas}} & \textbf{Índice de Rebentamento (\si{kPa.m^2.g^{-1}})} & 1,76  & 2,1   & 2,3   & 2,3 \\
  &  \textbf{Índice de Tracção (\si{N.m.g^{-1}})} & 34,6  & 37,2  & 42,5  & 43,4 \\
  &  \textbf{Extensão (\%)} & 2,9   & 2,7   & 2,8   & 2,6 \\
  &  \textbf{Tensile Stiffness (\si{kN.m^{-1}})} & 535  & 521,7 & 593,7 & 609,6 \\
  &  \textbf{Índice T.E.A. (\si{J.g^{-1}})} & 0,7   & 0,7   & 0,9   & 0,8 \\
  &  \textbf{Índice de Rasgamento (\si{mN.m^2.g^{-1})}} & 5,6   & 5,7   & 5,7   & 5,5 \\
\addlinespace
\multirow{3}{*}{\rotatebox[origin=C]{90}{Ópticas}} &   \textbf{C.E.D.L. (\si{m^2.kg^{-1})}} & 48,5  & 47,6  & 43,4  & 43,7 \\
  &  \textbf{Opacidade (\%)} & 88,1  & 88,1  & 86,2  & 85,9 \\
  &  \textbf{Brancura R457 (\%)} & 84,6  & 84,9  & 84,6  & 85,8 \\
    \cmidrule[0.8pt]{2-6}
    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%

\end{document}

or using dcolumn would look like

\documentclass{article}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage{multirow}

\usepackage[portuguese]{babel}
\usepackage[utf8]{inputenc}

\usepackage{siunitx}
\sisetup{locale = FR}
\usepackage{dcolumn}


\begin{document}

\begin{table}[htbp]
  \centering
  \caption{Add caption}
    \begin{tabular}{@{}ll*6{D{,}{,}{3.1}}@{}}
  \cmidrule[0.8pt]{2-6}
 & Amostra & \multicolumn{2}{c}{H60} & \multicolumn{2}{c}{H60 Modificado} \\
   \cmidrule{2-6}
  &  \textbf{Série} & \multicolumn{1}{c}{1}  & \multicolumn{1}{c}{2}  &  \multicolumn{1}{c}{1}   & \multicolumn{1}{c}{2} \\
  &  \textbf{Data de Formação} & \multicolumn{1}{c}{10/mar} & \multicolumn{1}{c}{22/abr} & \multicolumn{1}{c}{08/abr} & \multicolumn{1}{c}{10/abr} \\
  &  \textbf{Data de Medição} & \multicolumn{1}{c}{27/mar} & \multicolumn{1}{c}{28/abr} & \multicolumn{1}{c}{11/abr} & \multicolumn{1}{c}{11/abr} \\
\addlinespace
  \multirow{6}{*}{\rotatebox[origin=C]{90}{Estruturais}} & \textbf{Filler Efectivo (\%)} & 18,25 & 18,3  & 17,6  & 17,1 \\
  & \textbf{Gramagem (\si{g.m^{-2}})} & 83,8  & 85,0  & 82,8  & 83,0 \\
  & \textbf{Massa Volúmica (\si{g.cm^{-3}})} & 0,72  & 0,7   & 0,7   & 0,7 \\
  & \textbf{Índice de Mão (\si{cm^3.g^{-1}})} & 1,40  & 1,4   & 1,5   & 1,5 \\
  & \textbf{Resistência ao ar Gurley \SI{100}{ml} (\si{s})} & 3,8   & 5,3   & 4,1   & 3,4 \\
  & \textbf{Rugosidade  ar Bendtsen, FL (\si{ml.min^{-1}})} & 192   & 199,8 & 414,1 & 410,2 \\
\addlinespace
\multirow{6}{*}{\rotatebox[origin=C]{90}{Mecânicas}} & \textbf{Índice de Rebentamento (\si{kPa.m^2.g^{-1}})} & 1,76  & 2,1   & 2,3   & 2,3 \\
  &  \textbf{Índice de Tracção (\si{N.m.g^{-1}})} & 34,6  & 37,2  & 42,5  & 43,4 \\
  &  \textbf{Extensão (\%)} & 2,9   & 2,7   & 2,8   & 2,6 \\
  &  \textbf{Tensile Stiffness (\si{kN.m^{-1}})} & 535  & 521,7 & 593,7 & 609,6 \\
  &  \textbf{Índice T.E.A. (\si{J.g^{-1}})} & 0,7   & 0,7   & 0,9   & 0,8 \\
  &  \textbf{Índice de Rasgamento (\si{mN.m^2.g^{-1})}} & 5,6   & 5,7   & 5,7   & 5,5 \\
\addlinespace
\multirow{3}{*}{\rotatebox[origin=C]{90}{Ópticas}} &   \textbf{C.E.D.L. (\si{m^2.kg^{-1})}} & 48,5  & 47,6  & 43,4  & 43,7 \\
  &  \textbf{Opacidade (\%)} & 88,1  & 88,1  & 86,2  & 85,9 \\
  &  \textbf{Brancura R457 (\%)} & 84,6  & 84,9  & 84,6  & 85,8 \\
    \cmidrule[0.8pt]{2-6}
    \end{tabular}%
  \label{tab:addlabel}%
\end{table}%

\end{document}

Both packages have documentation giving details of how to achieve this: I'm not clear which part of the process specifically caused issues here (perhaps commas rather than decimal points?).

  • Just out of interest: Why not use \si{\g\per\square\m} instead of \si{g.m^{-2}} (and equivalently for the other units)? Also, shouldn't \% be \si{\percent}? – Svend Tveskæg Jun 19 '14 at 0:40
  • 1
    @SvendTveskæg I was sticking to the OP's syntax other than fixing actual errors: siunitx is designed to handle 'literal' input, and % is a bit of an odd one (it's not a unit but is supported as it's convenient!). – Joseph Wright Jun 19 '14 at 6:03

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.