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.
2 Answers
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
References
-
1
-
Actually I notice that, even without (setq org-export-with-smart-quotes t) it renders ' for html but not for latex nor beamer exports.– mhartmNov 4, 2014 at 5:53
-
@mhartm I thought of smartquotes and upquotes as the same. The second solution should resolve your question. Nov 4, 2014 at 17:39
I misunderstood your question when writing my first answer. Here's a second try, tested out.
Solution
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: } #+LaTeX_HEADER: \newcommand*{\@textalltt}[1]{% #+LaTeX_HEADER: #1% #+LaTeX_HEADER: \endgroup #+LaTeX_HEADER: } #+LaTeX_HEADER: \makeatother #+MACRO: UPQUOTE @@latex:\textalltt{'}@@ Without upquotes: 'How' about this? With upquotes: {{{UPQUOTE}}}How{{{UPQUOTE}}} about this?
Requirements
alltt
andupquote
LaTeX packages. If you use TexLive, you can dotlmgr install alltt
andtlmgr install upquote
.
References
-
1Thanks, but I want upquotes always to be upquotes, like when text is exported to html. I don't want to add {{{UPQUOTE}}} each time...– mhartmNov 5, 2014 at 4:39