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 using the MacTeX 2011 Distribution on OSX Lion (both with all updates installed) and I get a strange error from the siunitx package, that did not occur with MacTex 2010 on Snow Leopard.

As a minimal example

\documentclass{article}
\usepackage{siunitx}
\sisetup{mode=text,per-mode=symbol,input-symbols={\pi\cdot}}
\begin{document}
\SI{2 \pi \cdot 10}{\kilo\hertz}
\end{document}

will fail to be typeset with the error Missing $ inserted., whereas changing the \SI command to

\SI{2 \pi \cdot 1}{\kilo\hertz}

will be typeset with no errors.

Can someone explain, why siunitx fails to parse the first command correctly?

share|improve this question

2 Answers 2

up vote 8 down vote accepted

If you force text mode for output, it is down to you to ensure that math mode is selected for symbols which require it. As egreg has pointed out, one option is simply to turn off the parser and allow any math mode material in the number. The alternative approach requires that you create a suitable wrapper for each math mode symbol:

\documentclass{article}
\usepackage{siunitx}
\sisetup{mode=text,per-mode=symbol,input-symbols=\mypi\mycdot}
\protected\def\mypi{\ensuremath{\pi}}
\protected\def\mycdot{\ensuremath{\cdot}}
\begin{document}
\SI{2 \mypi \mycdot 10}{\kilo\hertz}
\end{document}
share|improve this answer
    
Thanks! That solves this issue. Any idea why this was no problem with MacTex 2010 ? –  TFG Dec 12 '11 at 11:33
    
@TFG I'd need to know which siunitx version we are talking about. 'MacTeX 2010' covers a lot, depending on when you updated it. –  Joseph Wright Dec 12 '11 at 11:51
    
According to texdoc I am using the version released on 2011/12/09 right now. The version I used before and that had no problems with this notation was released on 2010/7/15. –  TFG Dec 12 '11 at 12:01
    
@TFG I'd need to see your full log. This does not work for me with any release of siunitx that I know of! (E-mail directly to me might be best: joseph.wright@morningstar2.co.uk) –  Joseph Wright Dec 12 '11 at 12:14

You have to turn off the number parsing in the first argument:

\SI[parse-numbers=false]{2\pi\cdot10}{\kilo\hertz}

Page 22 of the documentation.

share|improve this answer

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.