1

I have a table contains tens, hundreds, or thousands numbers with or without decimal. I need those numbers to be aligned at ",", the decimal symbol (Indonesian). I try to use \newcommand\ph{$\phantom{1}$} but it doesn't work well. The number posisition didn't aligned at ",". Please help, thank you.

This is my MWE:

\documentclass[10pt,a4paper]{article}  
\usepackage[utf8]{inputenc}  
\usepackage[T1]{fontenc}  
\usepackage{amsmath}  
\usepackage{amsfonts}  
\usepackage{amssymb}  
\usepackage{graphicx}  
\usepackage{multirow}  
\newcommand\ph{$\phantom{1}$}  

\begin{document}  
    \begin{table}[h]  
        \centering  
        \caption{Hasil Belajar Matematika}  
        \begin{tabular}{l|c|c|c|c}  
            \hline  
\multirow{2}{*}{Statistik}& \multicolumn{2}{c|} {Eksperimen}&\multicolumn{2}{|c}{Kontrol}\\  
            \cline{2-5}  
            & {Pre-tes} &  Pos-tes  & Pre-tes   & Pos-tes   \\  
            \hline  
            Sampel          &   24      &    24     &        24 &  24   \\  
            Jumlah          &   928     &   1491    &   1184    &1585   \\    
            Rata-rata       &   48,46   &    77,83  &    49,50  & 66,12 \\  
            Maksimum        &   75      &    100    &   70      &94     \\  
            Minimum         &   26      &    43     &   33      &35     \\    
            Std. Deviasi    &   13,603  &    16,029 &   12,022  &15,066 \\  
            Varians         &   185,042 &    256,928&   144,522 &226,984\\  
            \hline  
        \end{tabular}  
    \end{table}  
\end{document}  
4

Use siunitx's S column type to align commas.

\documentclass{article}
\usepackage{multirow}
\usepackage{siunitx}
\sisetup{output-decimal-marker = {,}}
\usepackage{booktabs}
\begin{document}
\begin{table}[t]
  \centering
  \begin{tabular}{@{}l S S S S@{}}
    \toprule
    \multirow{2}{*}{Statistik}& \multicolumn{2}{c} {Eksperimen}&\multicolumn{2}{c}{Kontrol}\\  
        \cmidrule{2-5}  
        & {Pre-tes} &  {Pos-tes}    & {Pre-tes} & {Pos-tes} \\  
        \midrule
        Sampel          &   24      &    24     &        24 &  24   \\  
        Jumlah          &   928     &   1491    &   1184    &1585   \\    
        Rata-rata       &   48,46   &    77,83  &    49,50  & 66,12 \\  
        Maksimum        &   75      &    100    &   70      &94     \\  
        Minimum         &   26      &    43     &   33      &35     \\    
        Std. Deviasi &  13,603  &    16,029 &   12,022  &15,066 \\  
        Varians         &   185,042 &    256,928&   144,522 &226,984\\  
        \bottomrule
  \end{tabular}
\end{table}
\end{document}

enter image description here

Some notes:

  • Use booktabs to "beautify" your table.
  • Don't use vertical lines. Never use vertical lines. They are just too ugly.
  • You should not use h alone in floating environments.
| improve this answer | |
  • 2
    Why h shouldn't be used at floating environments? More correct is alone, but in combination [ht] or [htb] or `htbp]˙ are very fine ... – Zarko Dec 29 '19 at 4:07
  • @Zarko Yes, alone. Sorry, my bad :) – fractal Dec 29 '19 at 4:12

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