9

I have a sentence with the words 42 m s^{-1}. When this is exported to LaTeX it exports as 42 m s$^{\text{-1}}$. How should I write it, or what flags should I set in the #+OPTIONS: line, so that it exports as 42 m s^{-1}?

10

Also, it is good to know that the dollar syntax $...$ is not always recommended in LaTeX (and the double dollar syntax, $$...$$, for displayed equations, in strongly discouraged). For further info see this and this question on TeX.SE.

Needless to say, Org-mode supports both \(...\) and \[...\]. Try exporting this to LaTeX:

* Dollars
hello $E=mc^2$
* Parens
hello \(E=mc^2\)
* Double dollars
hello $$E=mc^2$$
* Brackets
hello \[E=mc^2\]
  • 1
    Yes, but note that these all cause issues with pandoc, except for the $foo$ syntax. – mankoff Oct 27 '14 at 1:35
  • Oh hi there, mbork! :) I do have to wonder if org-mode would be able to transform double-dollar to the more proper \[…\] as part of its export process. (It's more of a rhetorical wondering, I suppose—of course you can customize it :)) – Sean Allred Oct 27 '14 at 3:04
  • @mankoff: I'd consider this a bug in pandoc, then. Dollars (especially the double ones) are not proper LaTeX syntax. – mbork Oct 27 '14 at 7:49
  • I'd like to point out the comment section of one of the linked answers: tex.stackexchange.com/questions/510/… – Sean Allred Jul 29 '15 at 17:44
7

Just wrap it with the TeX-dollars:

$x^2$

exports to

...
$x^2$
...
  • Would the downvoter care to leave a comment noting how this answer may be improved? – Sean Allred Mar 2 '17 at 3:47
  • I was not me but LaTeX dollar syntax is discouraged, as discussed above. I guess that could be why. – Thriveth Mar 31 '17 at 0:26
  • @Thriveth $ isn't going anywhere – see Frank's comment as linked above; Frank has been in a leadership position with LaTeX for many years now, so his word carries quite a bit of weight. – Sean Allred Mar 31 '17 at 5:34
  • You are arguing with the wrong guy... All I know is that $ is officially discouraged, and I simply guessed that could be the reason why someone else had downvoted this. I am not claiming to be knowledgeable or for that matter having an opinion about whether this is a good idea or not. – Thriveth Apr 7 '17 at 14:23
  • @Thriveth I guess my point is I don't know where you're getting your info -- it needs to be updated. Do you mind sharing? – Sean Allred Apr 7 '17 at 16:32
5

Actually, in this case where you are working with units, you might consider using the siunitx LaTeX package. After loading the package in your org file:

#+LaTeX_+HEADER: \usepackage{siunitx} 

you can use \SI{42}{m.s^{-1}} in your text. This will make sure that the spaces between quantity and unit are appropriate, e.g. not allowing line breaks between any of the components. Moreover, the siunitx package also knows how to properly format numbers like 1.23e45 as 1.23 \times 10^{45}, etc.

  • Shouldn't it be \SI{42}{\meters\per\second}? I love siunitx, but I don't think it works with pandoc and I have to be able to convert to Word... – mankoff Oct 28 '14 at 12:55
  • You can use either (see e.g. page 5 of the documentation, just above section 4). I personally think the explicit \meters\per\second way is too much work :-). – ph0t0nix Oct 28 '14 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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