我正在使用 siunitx,并且我有一列包含数值和单位,结果如下
右侧的单位溢出了。如何拉伸表格以适应?
梅威瑟:
\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{bm}
\DeclareSIUnit\year{yr}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{l l c S[table-format=2.3]}
\toprule
Sensor &Parameter &Variable &{Value}\\
\midrule
\multirow{2}{*}{Accelerometer}
&Noise Density &- &60\si{\micro\g\per\sqrt{\hertz}}\\
&Bias Stability &- &15\si{\micro\g}\\
Compass &Noise Variance &$\nu_c$ &0.01\si{(\degree)\squared} \\
{dvl} &Noise Variance &$\bm\nu_{dvl}$ &0.01\si{(\meter\per\second)\squared} \\
{gnss} &Noise Variance &$\bm\nu_p$ &5\si{(\meter)\squared} \\
\multirow{2}{*}{Gyroscope}
&Noise Density &- &0.01\si{\degree\per\second\per\sqrt\hertz}\\
&Bias Stability &- &10\si{\degree\per\hour}\\
Magnetometer &Noise Std. Dev. &$\nu_m$ &3.35\si{\nano\tesla}\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案1
我将使用单独的列作为单位,跳过值的对齐并修复两列之间的间距:
\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{bm}
\usepackage{booktabs}
\usepackage{collcell}
\usepackage{siunitx}
\DeclareSIUnit\year{yr}
\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{@{} l l c S[table-parse-only, table-alignment = right] @{\,} >{\collectcell\si} l <{\endcollectcell} @{}}
\toprule
Sensor &Parameter &Variable &{Value}\\
\midrule
Accelerometer
&Noise Density &- &60 & \micro\g\per\sqrt{\hertz}\\
&Bias Stability &- &15 &\micro\g \\
Compass &Noise Variance &$\nu_c$ &0.01 & (\degree)\squared \\
{dvl} &Noise Variance &$\bm\nu_{dvl}$ &0.01 & (\meter\per\second)\squared \\
{gnss} &Noise Variance &$\bm\nu_p$ &5 & (\meter)\squared \\
Gyroscope
&Noise Density &- &0.01 & \degree\per\second\per\sqrt\hertz\\
&Bias Stability &- &10 & \degree\per\hour \\
Magnetometer &Noise Std. Dev. &$\nu_m$ &3.35 & \nano\tesla \\
\bottomrule
\end{tabular}
\end{table}
\end{document}