3

I'm trying to write very long lines of underlined text containing percentages using soul for allowing linebreaking and siunitx for getting the right spacing, as I do in the rest of the document.

Unfortunately, when I try to compile, I get the following error:

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

Here's a 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}

Does anybody know how can I fix this?

0

1 Answer 1

4

By far the easiest way is to group the entire \SI block in braces:

\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}
3
  • Using a pair of braces is indeed easier than the solution I was going to post, which was to use and \mbox wrapper...
    – Mico
    Dec 10, 2017 at 9:52
  • Thanks for the answer, it does actually resolve the compile error. Do you also know how to keep the text in italics?
    – Alessandro
    Dec 10, 2017 at 9:56
  • 2
    @Alessandro \sisetup{detect-mode, detect-shape} or all kind of detections: \sisetup{detect-all}. Dec 10, 2017 at 11:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .