Search code examples
emacslatexwhitespaceorg-mode

How to make non-breaking spaces (ties) in Org-mode that exports properly to LaTeX


In (La)TeX non-breaking spaces are called ties and they are made by ~. Ties are for instance used after abbreviations so that there is no line break directly after them and so that dots ending abbrevations are not treated as ending sentences. The latter use is important because standardly LaTeX puts a longer space after dots than between words.

When exporting from Org-mode to LaTeX ~ is treated as an explicit character and not as a tie. Ignoring the use of non-breaking spaces is not an alternative because it leads to the wrong spacing (see the second sentence in the example above). One alternative is to force Org-mode to treat ~ as LaTeX with #+BEGIN_LaTeX ~ #+END_LaTeX but it is verbose and export to other formats breaks. Finally, using UTF-8 non-breaking spaces, as suggested in http://comments.gmane.org/gmane.emacs.orgmode/24716, does not work because LaTeX does not treat it as a space. So, how can I use non-breaking spaces in Org-mode that are properly exported to LaTeX?

Here is an example to clarify. The first sentence fails because ~ is treated as an explicit character. The second sentence fails, obviously, because the last dot is treated as ending a sentence by LaTeX. The third sentence exports properly but it is verbose and breaks export to other formats. The fourth line (separated by an UTF-8 non-breaking space which is inserted by C-x 8 Space) fails because it is not treated as a space by LaTeX:

#+title:Title

e.g.~example

e.g. example

#+BEGIN_LaTeX
e.g.~example
#+END_LaTeX

e.g. example

This exports (C-x C-e L) to the following LaTeX code:

e.g.\~{}example

e.g. example

e.g.~example

e.g. example

Which renders as:

LaTeX rendered

I am running Org-mode 7.6 in Emacs 23.3.1.


Solution

  • On http://orgmode.org/manual/Special-symbols.html I found the solution to the double spacing problem:

    Org

    e.g.\nbsp{}example
    

    LaTeX

    e.g.~example