I have some verbatim text containing a tilde, =some ~ text=. Now, org-mode is supposed to leave the tilde alone. However, upon exporting with the latex backend, I get the following in my .tex: \texttt{some \textasciitilde{} text}, which is not the same, as it is rendered as a "high" tilde versus a centered tilde.

Now, in normal text I can work around this by some Latex command that forces the centered tilde. However, this is inpossible in verbatim, as commands do get translated to Latex as-is, so it would say \texttt{some \midtide text} instead.

Anyone that knows why this is? A solution would be to insert =@@latex:~@@= which is some "super-verbatim" that actually does just plop in the tilde, however this only works on the Latex backend. As I also export to HTML I would like to keep my document as backend-unaware as possible.

2 Answers 2


This is a problem with the CM fonts. The link shows some workarounds, but for your purposes (going from an org mode file to a PDF) I think the easiest/best thing to do is to use a different set of fonts. You can try Palatino e.g. by adding this to your org mode file:

#+LATEX_HEADER: \usepackage{palatino}

You'll have to install whatever fonts you decide to use, but that might be an advantage: a lot of people dislike the CM fonts and prefer something else. If you like the Palatino look, you can add it permanently by adding something like this to your initialization file:

(eval-after-load "org"
     (add-to-list 'org-latex-packages-alist '("" "palatino" nil)))

You can do some find-replace only before exporting, in a behind-the-scene copy file to be exported, without changing the actual original org file you are composing. Check org manual 13.17, this section gives me the inspiration to patch up the following elisp to do what you want for latex export:

(defun me/impose-latex-tilde-from-verbatim (backend)
  "replace org verbatim tilde into latex verbatim tilde"
      (search-forward "=~=" nil t)
    (replace-match "@@latex:~@@"))

(add-hook 'org-export-before-parsing-hook #'me/impose-latex-tilde-from-verbatim)

Note that the above function takes a backend argument, you can use it to check the export backend used, and then decide what to use to replace your =~=.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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