15

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}?

mankoff
  • 4,108
  • 1
  • 22
  • 39
  • 1
    I just wrap everything in `$$`, the options you are looking for are probably these: http://orgmode.org/manual/LaTeX-fragments.html#LaTeX-fragments – wvxvw Oct 26 '14 at 17:35

3 Answers3

15

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\]
mbork
  • 1,647
  • 1
  • 13
  • 23
  • 2
    Yes, but note that these all cause issues with `pandoc`, except for the $foo$ syntax. – mankoff Oct 27 '14 at 01: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 03: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 07:49
  • I'd like to point out the comment section of one of the linked answers: http://tex.stackexchange.com/questions/510/are-and-preferable-to-dollar-signs-for-math-mode#comment83898_513 – Sean Allred Jul 29 '15 at 17:44
8

Just wrap it with the TeX-dollars:

$x^2$

exports to

...
$x^2$
...
Sean Allred
  • 6,861
  • 16
  • 85
  • Would the downvoter care to leave a comment noting how this answer may be improved? – Sean Allred Mar 02 '17 at 03: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 00:26
  • @Thriveth [`$` isn't going anywhere](http://tex.stackexchange.com/a/513/17423) – 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 05: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 07 '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 07 '17 at 16:32
7

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.

ph0t0nix
  • 1,119
  • 13
  • 28
  • 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