문서의 모든 숫자를 소수점 이하 자릿수로 변환

문서의 모든 숫자를 소수점 이하 자릿수로 변환

모든 숫자의 형식을 소수점 이하 두 자리까지 자동으로 지정해야 하는 테이블이 있습니다. 이것이 가능한가? 아니면 전체 문서의 형식을 지정해야 합니까?

편집하다:

답변에 제안된 코드를 적용했지만 안타깝게도 내 특정 테이블에서는 작동하지 않는 것 같습니다! 그에 맞게 조정하는 방법에 대한 아이디어가 있는 사람이 있습니까?

\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}

답변1

소수점이 있는 각 열을 -columns로 정의해야 합니다 S.

표에는 31개의 열이 있으며 일부는 소수, 일부는 수학 기호가 있고 일부는 비어 있습니다. 빈 곳에 emdash(추적을 위해)를 넣었습니다.

다음은 MWE(최소 작업 예제)입니다. 나는 scrartcl페이지 여백 사이에 표 형식을 압축하기 위해 높은 DIV 요소와 가로 모드를 사용했습니다. geometry올바른 매개변수와 함께 -package를 사용하여 동일한 결과를 얻을 수 있습니다 .

\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}

여기에 이미지 설명을 입력하세요

답변2

57페이지를 참조하세요.siunitx선적 서류 비치.

작은 예:

\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}

관련 정보