Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to rceord some changes using the changes package - I've already done a lot of the text, and had to work around display maths but I've got a simply value typeset using siunitx, and changing that value doesn't appear to work:

\documentclass{article}
\usepackage{siunitx}
\usepackage{changes}
\begin{document}
    \replaced{\SI{1}{\volt}}{\SI{2}{\volt}}
\end{document}

gives:

! Extra }, or forgotten \endgroup.
\UL@stop ...z@ \else \UL@putbox \fi \else \egroup 
                                                  \egroup \UL@putbox \fi \if...
l.5 ...\SI{1}{\volt}}{\SI{2}{\volt}}

If I continue to compile (getting the same error again and 2 missing } inserteds, the output is actually exactly as expected:

surprisingly correct output of above code

adding \protect before the \SI gives exactly the same error, and of course trying \SI{\replaced{1}{2}}{\volt} was never going to work:

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! siunitx error: "invalid-token-in-number"
! 
! Invalid token '\let ' in numerical input.
! 
! See the siunitx documentation for further information.
! 
! For immediate help type H <return>.
!...............................................  

Is there some workaround that will get this to run without errors? I don't really want to run in nonstopmode in case of "real" errors, and besides, I used a build script that's designed to stop on errors.

share|improve this question

1 Answer 1

up vote 6 down vote accepted

The problem here is actually an interaction with the \sout command from the ulem package. Essentially, there is a clash over the insertion of a \penalty between the number and the unit: ulem alters how this expects to work and that doesn't agree with the box/grouping in siunitx. I've not traced it all back to a minimal example of the low-level code, but that probably wouldn't help in any case (at least without quite a bit of effort). What you can do is simply disable the insertion of a penalty. There isn't an interface for this (one of the few things not in the options for siunitx!) so at the moment a low-level redefinition is required

\documentclass{article}
\usepackage{siunitx}
\usepackage{changes}
\ExplSyntaxOn
\cs_set_eq:NN \__siunitx_unit_output_number_sep:
  \__siunitx_unit_output_number_sep_aux:
\ExplSyntaxOff
\begin{document}
    \replaced{\SI{1}{\volt}}{\SI{2}{\volt}}
\end{document}
share|improve this answer
    
That's great, thank you. But is there a downside - i.e. should I be undoing this fix when I switch from [draft] to [final]? –  Chris H Sep 2 at 9:35
1  
@ChrisH Yes, I would. The penalty is there to prevent or at least discourage a line break between the number and the unit. –  Joseph Wright Sep 2 at 9:47
    
Now I think about it, I'm using a non-breaking space as my separator, so on the face of it I shouldn't need a penalty anyway. But of course I've no way of knowing whether it could break despite this. –  Chris H Sep 2 at 11:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.