Convertir todos los números del documento para establecer el número de decimales

Convertir todos los números del documento para establecer el número de decimales

Tengo una tabla que necesito para formatear automáticamente todos los números con dos decimales. es posible? ¿O necesito formatear todo el documento?

EDITAR:

¡He aplicado el código sugerido en una respuesta pero desafortunadamente no parece funcionar para mi tabla específica! ¿Alguien tiene alguna idea sobre cómo adaptarlo en consecuencia?

\documentclass{article}
\usepackage{siunitx}
\begin{document}

\sisetup{
table-number-alignment = center,
table-figures-integer = 1,
table-figures-decimal = 2
}

\begin{table}[thb]

\caption{\label{labelname}Table Caption}

\scriptsize
{\centering \begin{tabular
{lr@{\hspace{0cm}}c@{\hspace{0cm}}rr@{\hspace{0cm}}c@{\hspace{0cm}}r@{\hspace{0.1cm}}cr@{    space{0cm}}c@{\hspace{0cm}}r@{\hspace{0.1cm}}cr@{\hspace{0cm}}c@{\hspace{0cm}}r@{\hspace{0
1cm}}cr@{\hspace{0cm}}c@{\hspace{0cm}}r@{\hspace{0.1cm}}cr@{\hspace{0cm}}c@{\hspace{0cm}}r
{\hspace{0.1cm}}cr@{\hspace{0cm}}c@{\hspace{0cm}}r@{\hspace{0.1cm}}cr@{\hspace{0cm}}c@{\hs
ace{0cm}}r@{\hspace{0.1cm}}c}

\\
\hline
Dataset & \multicolumn{3}{c}{ConjunctiveRule }& \multicolumn{4}{c}{DecisionTable } &
\multicolumn{4}{c}{DTNB } & \multicolumn{4}{c}{JRip} & \multicolumn{4}{c}{NNge} &
\multicolumn{4}{c}{OneR} & \multicolumn{4}{c}{PART} & \multicolumn{4}{c}{Ridor} \\
\hline
Number correct & 9.5900 & $\pm$ & 1.16 & 9.5600 & $\pm$ & 1.22 &         & 9.5600 & $\pm$ &
1.22 &         & 9.5000 & $\pm$ & 1.24 &         & 8.9500 & $\pm$ & 1.34 &         & 9.6000
& $\pm$ & 1.16 &         & 9.3000 & $\pm$ & 1.34 &         & 9.1700 & $\pm$ & 1.42 &        \

\end{tabular} \scriptsize \par}
\end{table}
\end{document}

Respuesta1

Tienes que definir cada columna con cifras decimales como Scolumnas.

Tienes 31 columnas en tu tabular, algunas con decimales, otras con un signo matemático y otras vacías. En el vacío le he puesto un emdash(para llevar la cuenta).

Aquí hay un MWE (ejemplo de trabajo mínimo). Utilicé scrartclun factor DIV alto y modo horizontal para comprimir el cuadro entre los márgenes de una página. Puedes lograr lo mismo usando el geometrypaquete con el parámetro correcto:

\documentclass[a4paper,landscape,DIV=20]{scrartcl}
\usepackage{siunitx}
\begin{document}
\sisetup{
  table-number-alignment = center,
  table-figures-integer = 1,
  table-figures-decimal = 2
}
\begin{table}[thb]
\caption{\label{labelname}Table Caption}
\centering\tiny
\begin{tabular}{
    l
    S[table-auto-round]
    c
    S[table-auto-round]
    S[table-auto-round]
    c
    S[table-auto-round]
    l
    S[table-auto-round]
    c
    S[table-auto-round]
    l
    S[table-auto-round]
    c
    S[table-auto-round]
    l
    S[table-auto-round]
    c
    S[table-auto-round]
    l
    S[table-auto-round]
    c
    S[table-auto-round]
    c
    S[table-auto-round]
    c
    S[table-auto-round]
    c
    S[table-auto-round]
    c
    S[table-auto-round]
    l}

Dataset & \multicolumn{3}{c}{ConjunctiveRule }& \multicolumn{4}{c}{DecisionTable } &
\multicolumn{4}{c}{DTNB } & \multicolumn{4}{c}{JRip} & \multicolumn{4}{c}{NNge} &
\multicolumn{4}{c}{OneR} & \multicolumn{4}{c}{PART} & \multicolumn{4}{c}{Ridor} \\

Number correct & 
9.5900 & 
$\pm$ & 
1.16 & 
9.5600 & 
$\pm$ &
1.22 &
--- &
9.5600 &
$\pm$ &
1.22 &
--- & 
9.5000 & 
$\pm$ & 
1.24 &
--- &
8.9500 & 
$\pm$ &
 1.34 &
--- & 
9.6000 & 
$\pm$ & 
1.16 & 
--- & 
9.3000 & 
$\pm$ 
& 1.34 & 
--- & 
9.1700 & 
$\pm$ &
 1.42 &
--- \\ 
\end{tabular}
\end{table}
\end{document}

ingrese la descripción de la imagen aquí

Respuesta2

Consulte la página 57 delsiunitxdocumentación.

Un pequeño ejemplo:

\documentclass{article}
\usepackage{siunitx}
\begin{document}
\sisetup{
  table-number-alignment = center,
  table-figures-integer = 1,
  table-figures-decimal = 2
}
\begin{tabular}{
    S[table-auto-round]
  }
  2.\\
  2.3\\
  2.34\\
  2.345
\end{tabular}
\end{document}

información relacionada