How can I get org-babel to properly render ' and not ’ when exporting to LaTeX and to Beamer? I didn't find any good solution yet, and I would like the code to be copy-pasteable.

| improve this question | | | | |

Smart quotes render 'text' as `text' in LaTeX.

That can be done in following ways.

Enable smart quotes for all exports

Put this in your init.el after loading org-mode.

(setq org-export-with-smart-quotes t)

Enable smart quotes on export only a particular org file

Put this in the beginning of the org file.

#+OPTIONS: ':t


| improve this answer | | | | |
  • 1
    I tried this solution but still get the same issue. – mhartm Nov 4 '14 at 5:14
  • Actually I notice that, even without (setq org-export-with-smart-quotes t) it renders ' for html but not for latex nor beamer exports. – mhartm Nov 4 '14 at 5:53
  • @mhartm I thought of smartquotes and upquotes as the same. The second solution should resolve your question. – Kaushal Modi Nov 4 '14 at 17:39

I misunderstood your question when writing my first answer. Here's a second try, tested out.


You need to use a combination of alltt and upquote latex packages. Here is my solution based on the below referenced solutions from TeX SE and the use of org-mode Macro Replacement.

The below MWE was tested on emacs -Q, emacs 24.4.

#+LaTeX_HEADER: \usepackage{alltt}
#+LaTeX_HEADER: \usepackage{upquote}

#+LaTeX_HEADER: \makeatletter
#+LaTeX_HEADER: \newcommand*{\textalltt}{}
#+LaTeX_HEADER: \DeclareRobustCommand*{\textalltt}{%
#+LaTeX_HEADER:   \begingroup
#+LaTeX_HEADER:     \let\do\@makeother
#+LaTeX_HEADER:     \dospecials
#+LaTeX_HEADER:     \catcode`\\=\z@
#+LaTeX_HEADER:     \catcode`\{=\@ne
#+LaTeX_HEADER:     \catcode`\}=\tw@
#+LaTeX_HEADER:     \verbatim@font\@noligs
#+LaTeX_HEADER:     \@vobeyspaces
#+LaTeX_HEADER:     \frenchspacing
#+LaTeX_HEADER:     \@textalltt
#+LaTeX_HEADER: \newcommand*{\@textalltt}[1]{%
#+LaTeX_HEADER:     #1%
#+LaTeX_HEADER:   \endgroup
#+LaTeX_HEADER: \makeatother

#+MACRO: UPQUOTE @@latex:\textalltt{'}@@

Without upquotes: 'How' about this?

With upquotes: {{{UPQUOTE}}}How{{{UPQUOTE}}} about this?

enter image description here


  • alltt and upquote LaTeX packages. If you use TexLive, you can do tlmgr install alltt and tlmgr install upquote.


  • How to make a real apostrophe or single-quote in LaTeX - TeX-SE
  • alltt package's \alltt{} makes a newline - TeX-SE
| improve this answer | | | | |
  • Thanks, but I want upquotes always to be upquotes, like when text is exported to html. I don't want to add {{{UPQUOTE}}} each time... – mhartm Nov 5 '14 at 4:39

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.