如何用灵魂给 siunitx 数字加下划线?

如何用灵魂给 siunitx 数字加下划线?

我正在尝试使用以下方法编写包含百分比的很长的带下划线的文本灵魂允许换行和希尼奇以获得正确的间距,就像我在文档的其余部分中所做的那样。

不幸的是,当我尝试编译时,出现以下错误:

siunitx error: "invalid-token-in-number"
! 
! Invalid token '4' in numerical input.

以下是 MWE:

\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage{soul}
\usepackage{siunitx}
\sisetup{unit-mode = text, output-decimal-marker={,}}

\begin{document}

\textit{\ul{Very very very very very very very very very very long line of text. 40\% is printed without errors.}}

\ul{\textit{Very very very very very very very very very very long line of text. 40\% is printed without errors.}}

\ul{\textit{Very very very very very very very very very very long line of text. \SI{40}{\percent} gives the error}}

\end{document}

有人知道我该如何修复这个问题吗?

答案1

迄今为止最简单的方法是将整个\SI块用括号括起来:

\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage{soul}
\soulregister\SI{1}
\usepackage{siunitx}
\sisetup{unit-mode = text, output-decimal-marker={,}}

\begin{document}

\textit{\ul{Very very very very very very very very very very long line of text. 40\% is printed without errors.}}

\ul{\textit{Very very very very very very very very very very long line of text. 40\% is printed without errors.}}

\ul{\textit{Very very very very very very very very very very long line of text. {\SI{40}{\percent}} gives the error}}

\end{document}

相关内容