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.

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:

\documentclass{article}

\usepackage{siunitx}
\usepackage{soul}

\newcommand{\wibble}[1]{#1}

\begin{document}

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

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

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

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

\end{document}

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).
share|improve this question
    
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 '12 at 14:54
1  
For the moment you can add \leavevmode before \SI. –  egreg Jan 26 '12 at 15:34
    
Cheers egreg, this temporary solution seems to work. –  aghsmith Jan 26 '12 at 15:59
add comment

1 Answer

up vote 4 down vote accepted

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.

share|improve this answer
    
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 '12 at 16:14
add comment

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.