This problem seems somewhat obscure, it is potentially a bug in siunitx or soul (I am aware of issues with the latter). Which one is uncertain and I'm not certain that it is a bug.

What I want to do is to highlight some text in paragraph mode and then have a number+unit (using siunitx) immediately afterwards.

Here is some code:





   \paragraph{\hl{Hello}} \SI{12}{\meter}

   \hl{Hello} \SI{12}{\meter}

   \paragraph{\hl{Hello}} a \SI{12}{\meter}

   \paragraph{\hl{Hello}} \wibble{12~m}


So here, I have tried a few things out. The top example is the malfunctioning one. Instead of highlighting the text, it writes "hl" before the argument of the macro. There are no malfunctions with the following cases:

  • If not in paragraph mode (second example).
  • If I put something else between the paragraph macro and siunitx (third example).
  • If I use a different macro to siunitx after the paragraph macro (fourth example).
  • I suspect this is to do with the way \paragraph works in the standard classes (it is a sectioning command, but just dumps it's input directly under most circumstances). I need to review a few pieces of code: will have to be after work today!
    – Joseph Wright
    Jan 26, 2012 at 14:54
  • 1
    For the moment you can add \leavevmode before \SI.
    – egreg
    Jan 26, 2012 at 15:34
  • Cheers egreg, this temporary solution seems to work.
    – aghsmith
    Jan 26, 2012 at 15:59

1 Answer 1


As observed by egreg, this behaviour is fixed by adding \leavevmode before \SI. The reason for this is that \paragraph is a sectioning command, but adds the argument to \everypar rather than printing anything. This means that if the \SI (or similar) command is the very first thing after the \paragraph then the section heading ends up printed inside the group which \SI starts. That is an issue here as \hl is used as a macro abbreviation by siunitx (for hectolitre), and so behaves incorrectly.

This is clearly not desirable behaviour, and so counts as a bug in siunitx. I will update the code, fixing this, later today and upload to CTAN. I'll post an update here once CTAN is updated.

  • Thanks Joseph, I scooped the latest version (2.4j) of the your bitBucket repository and this has resolved the issue. I haven't been thorough though and checked if other things have changed. I'll close the issue.
    – aghsmith
    Jan 27, 2012 at 16:14

You must log in to answer this question.

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