
Eu tenho uma tabela que preciso formatar automaticamente todos os números com duas casas decimais. Isso é possível? Ou preciso formatar o documento inteiro?
EDITAR:
Apliquei o código sugerido em uma resposta, mas infelizmente não parece funcionar para minha tabela específica! Alguém tem alguma idéia de como adaptá-lo de acordo?
\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}
Responder1
Você deve definir cada coluna com números decimais como S
colunas.
Você tem 31 colunas em sua tabela, algumas com decimais, algumas com sinal matemático e algumas vazias. No vazio coloquei um emdash
(para acompanhar).
Aqui está um MWE (exemplo mínimo de trabalho). Usei scrartcl
um fator DIV alto e modo paisagem para espremer o tabular entre a margem de uma página. Você pode conseguir o mesmo usando o geometry
-package com o parâmetro correto:
\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}
Responder2
Veja a página 57 dosiunitx
documentação.
Um pequeno exemplo:
\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}