0

The following org-mode MCE points out a problem when one wants to export a backslash immediately followed by ordinary text (e.g. ~\~foo is exported to \textasciitilde{}$\backslash$~foo where one expects \texttt{\textbackslash{}}foo). As a poor man workaround, one can insert a line break between ~\~ and foo but this inserts a line break in the exported .tex file and hence a space in the resulting PDF.

How to workaround this issue?

~\~

~\foo~

~\~foo

~\~
foo

=\=

=\foo=

=\=foo

=\=
foo
7
  • Can you insert a non breaking space instead? \nbsp? Jun 14 at 13:21
  • 1
    If the non-breaking space workaround is not enough, do C-h v org-emphasis-regexp-components. There have been questions on that here (e.g. emacs.stackexchange.com/questions/60533/…).
    – NickD
    Jun 14 at 13:35
  • @JohnKitchin I would like to avoid spaces: I would like ~\~foo to result in fine in `foo (sigh, I can't get it to work with Markdown. In LaTeX, I want it to be \texttt{\textbackslash{}}foo`, hence no space between the backslash and "foo". Jun 14 at 19:10
  • @NickD Sigh... Why life (I mean org-mode) is so complicated? Compared to org-mode, LaTeX looks extremely simple :$ Jun 14 at 19:16
  • 1
    Well, 99.5% of simple things are simpler in Org than in LaTeX, but this certainly belongs to the other portion: simple things that are more complicated in Org. If you only want Latex output, then I would suggest using literal LaTeX in your org file with @@latex:\textt{\textbackslash}@@ as a simpler alternative, but that won't work for HTML export e.g. The desire to make things work across export backends is what complicates Org mode in this case.
    – NickD
    Jun 14 at 20:29
2

You can use a zero width space for this (https://orgmode.org/manual/Escape-Character.html). This will allow the code markup to work, but will not be visible in the export, or in the org file. That char acts like a space, but it has zero width. If you need this a lot there is a convenient function and key binding to insert a zero width space at https://thewanderingcoder.com/2015/03/emacs-org-mode-styling-non-smart-quotes-zero-width-space-and-tex-input-method/.

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.