테이블의 단위와 숫자를 정렬하는 방법

테이블의 단위와 숫자를 정렬하는 방법

표의 단위와 숫자를 어떻게 정렬할 수 있나요? siunitx로 시도했지만 작동하지 않습니다.

\begin{table}
    \centering
    \caption{Caption goes here.}
    \begin{tabular}[t]{lS}
        \toprule
        Substance   & Amounts \\ \midrule
        A           & 1 $mL$    \\
        B           & 100 $mg$  \\
        C           & 0.5 $mg$  \\
        D           & 82 $\mu L$   \\
        E           & 0.1 $g$   \\bottomrule
    \end{tabular}
\end{table}

많은 테이블이 필요하지 않기 때문에 가능하다면 수동으로 수행할 수도 있습니다. 미리 감사드립니다

답변1

이 같은?

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

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{siunitx,booktabs,array}

\begin{document}
\begin{table}
    \centering
    \caption{Caption goes here.}
    \begin{tabular}[t]{ @{} 
                        l 
                        S[table-format=2.1] 
                        @{\,} 
                        s[table-unit-alignment=left]
                        @{} }
        \toprule
        Substance   & \multicolumn{2}{c@{}}{Amounts} \\ 
        \midrule
        A           & 1   & \milli\liter    \\
        B           & 100 & \milli\gram  \\
        C           & 0.5 & \milli\gram  \\
        D           & 82  & \micro\liter    \\
        E           & 0.1 & \gram   \\
        \bottomrule
    \end{tabular}
\end{table}
\end{document}

관련 정보