使用 siunitx 将表格与单位垂直对齐

使用 siunitx 将表格与单位垂直对齐

我有以下 MWE 和输出:

\documentclass[a4paper]{article}
\usepackage[landscape]{geometry}
\usepackage{booktabs}
\usepackage{siunitx}
\sisetup{per-mode = reciprocal-positive-first
}
\DeclareSIUnit{\esu}{esu}

\begin{document}

\begin{table}
\centering
\sisetup{table-format=3.2}
\begin{tabular}{l c S[table-format=1.8] c c}
    \toprule
    Quantity & Symbol/Expression & {Values} & SI Units & cgs Units \\
    \midrule
    Speed of light in Vacuum & $c$ & 2.99792458 & \SI{e8}{\m.\s^{-1}} & \SI{e10}{\cm.\s^{-1}}\\
    Elementary Charge & $e$ & 4.8032068 & & \SI{e-10}{\esu.\s}\\
    \bottomrule
\end{tabular}
\end{table}

\end{document}

enter image description here

问题

为了两个都cgs 和 SI 单位列,如何使用siunitx包对齐单位?我的意思是cm s^{-1}esu s应该垂直对齐。目前它们彼此偏移,因为 10 上有负功率。

答案1

您可以将\Si{...}{...}材料分成两列:第一列(右对齐)包含\num{...}材料,第二列(左对齐)包含\si{...}材料。

enter image description here

\documentclass[a4paper]{article}
\usepackage[landscape]{geometry}
\usepackage{booktabs}
\usepackage{siunitx}
\sisetup{per-mode = reciprocal-positive-first}
\DeclareSIUnit{\esu}{esu}
\begin{document}

\begin{table}
\centering
\sisetup{table-format=3.2}
\begin{tabular}{l c S[table-format=1.8] r@{\,}l r@{\,}l}
    \toprule
    Quantity & Symbol/Expression & {Values} & 
    \multicolumn{2}{c}{SI Units} & 
    \multicolumn{2}{c}{cgs Units} \\
    \midrule
    Speed of light in vacuum & $c$ & 2.99792458 & 
    \num{e8}  & \si{\m.\s^{-1}} & 
    \num{e10} & \si{\cm.\s^{-1}}\\
    Elementary charge & $e$ & 4.8032068 & && 
    \num{e-10} & \si{\esu.\s}\\
    \bottomrule
\end{tabular}
\end{table}
\end{document}

答案2

也许您想要其中之一?它只需要eqparbox

\documentclass[a4paper]{article}
\usepackage[landscape]{geometry}
\usepackage{booktabs}
\usepackage{siunitx}
\sisetup{per-mode = reciprocal-positive-first
}
\DeclareSIUnit{\esu}{esu}
\usepackage{eqparbox}

\begin{document}

\begin{table}[!htb]
\centering
\sisetup{table-format=3.2}
\begin{tabular}{l c S[table-format=1.8] cl}
    \toprule
    Quantity & Symbol/Expression & {Values} & SI Units & \multicolumn{1}{c}{cgs Units} \\
    \midrule
    Speed of light in Vacuum & $c$ & 2.99792458 & \SI{e8}{\m.\s^{-1}} & \eqmakebox[U][l]{\num{e10}}\si{\cm.\s^{-1}}\\
    Elementary Charge & $e$ & 4.8032068 & & \eqmakebox[U][l]{\num{e-10}\,}\si{\esu.\s}\\
    \bottomrule
\end{tabular}
\end{table}

\begin{table}[!htb]
\centering
\sisetup{table-format=3.2}
\begin{tabular}{l c S[table-format=1.8] cl}
    \toprule
    Quantity & Symbol/Expression & {Values} & SI Units & \multicolumn{1}{c}{cgs Units} \\
    \midrule
    Speed of light in Vacuum & $c$ & 2.99792458 & \SI{e8}{\m.\s^{-1}} & \eqmakebox[U][r]{\num{e10}}\,\si{\cm.\s^{-1}}\\
    Elementary Charge & $e$ & 4.8032068 & & \eqmakebox[U][r]{\num{e-10}}\,\si{\esu.\s}\\
    \bottomrule
\end{tabular}
\end{table}

\end{document} 

enter image description here

相关内容