In Org-mode I can surround text with = or ~ to place text in inline verbatim or code mode.

However this fails if the text has quotes, and I couldn't find an explanation or workaround in the documentation.

For example:

  • =hello= Renders as verbatim
  • ~hello~ Renders as code
  • =hello'= Fails to render as verbatim
  • ~hello'~ Fails to render as code

The only solution that I found so far is inserting invisible characters, e.g. typing C-x 8 <RET> 200b <RET>, as explained in this question.

Why is this (is it a bug?) and how can I avoid this problem without inserting invisible characters?


First of all: This is Emacs. It's not a bug, it's a setting!

Secondly, @glucas is correct in saying that you need to modify org-emphasis-regexp-components to get what you want. However, I'd like to suggest two modifications to his (@Malabarba's) code and provide a bit more context:

  1. You don't need to copy the entire value of org-emphasis-regexp-components to your init-file to modify a single component. For your use case the following is sufficient:

    (setcar (nthcdr 2 org-emphasis-regexp-components) " \t\r\n,\"")
  2. You don't have to modify org-emphasis-regexp-components before loading org-mode via (require 'org). Just add the following line after your modifications:

    (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)

More context

In case you want to customize other aspects of how emphasis markup works in org-mode, know this:

The value of org-emphasis-regexp-components is a list with five entries.

  1. The first entry controls which characters are allowed to immediately precede markup characters. If you want to be able to have something like why=hello= render correctly, you'll need to modify this entry.

    (setcar org-emphasis-regexp-components "...")
  2. The second entry controls which characters are allowed to immediately follow markup characters. If you want to be able to have something like =hello=there render correctly, you'll need to modify this entry.

    (setcar (nthcdr 1 org-emphasis-regexp-components) "...")
  3. The third entry specifies the characters that are not allowed as border characters, i.e., characters that immediately follow an opening markup character or precede a closing markup character. You'll need to modify this to make things like ='hello'= render correctly.

    (setcar (nthcdr 2 org-emphasis-regexp-components) "...")
  4. The fourth entry lists characters that are allowed in the body of your marked up string, i.e., characters that appear between the border characters. You'll rarely need to modify this; by default, any character is allowed as a body character.

    (setcar (nthcdr 3 org-emphasis-regexp-components) "...")
  5. The fifth entry specifies how many newlines are allowed inside a marked up expression. By default, org-mode allows a single newline. So if you want to be able to add markup to text that spans more than two consecutive lines, you'll need to modify this entry.

    (setcar (nthcdr 4 org-emphasis-regexp-components) N)

    ... where N is the number of newlines you want to allow.

Related posts

People seem to run into this issue fairly frequently. Aside from the post you mentioned, there are at least two more questions on StackOverflow that deal with very similar issues:

  • 5
    I upvoted your answer but would also like to commend on the quality of the answer. – Kaushal Modi Jul 9 '15 at 16:53
  • Thanks @itsjeyd This works great If I run those two lines interactively once Emacs has fully loaded with my buffers already open. However, and strangely enough, I run into "Symbol's value as variable is void: org-emphasis-regexp-components" even if I place those two lines all the way at the bottom of my .emacs file. Any thoughts on why that could be the case? – Amelio Vazquez-Reina Jul 13 '15 at 13:17
  • @AmelioVazquez-Reina You're welcome :) Just to make sure: Do you (require 'org) in your .emacs file before making any customizations to org-emphasis-regexp-components? – itsjeyd Jul 13 '15 at 20:24
  • 1
    @AmelioVazquez-Reina I'm glad everything is working properly for you now :) Your observations are correct -- you don't need to (require 'org) in your init-file to be able to use it. If you don't, Emacs will load it automatically when you: (a) open an .org file for the first time in the current session, or (b) enable the mode manually via M-x org-mode for the first time in the current session, or (c) when it restores a saved desktop that includes at least one .org file. (contd.) – itsjeyd Jul 15 '15 at 5:51
  • 1
    @AmelioVazquez-Reina (contd.) The thing is: Emacs won't load org-mode automatically just because you put some customizations for it in your init-file. That's why you need to (require 'org) before customizing any of its variables. Without fully loading the mode, Emacs won't know what to do with variables like org-emphasis-regexp-components; they are not defined when Emacs first encounters them, hence the Symbol's value as variable is void message. – itsjeyd Jul 15 '15 at 5:58

There's a much simpler option: use inline source blocks:


This works without problems for characters like quotations marks, and it provides syntax highlighting for inline code.

To include the inline source code when exporting, you'll want to add this declaration to the header:

#+PROPERTY: header-args :exports code
  • This is a great tip! Very nice to get syntax highlighting for inline code! – Shon Feder Oct 15 '17 at 21:51
  • This is great! It reminds me Latex (: – Chris.Q May 23 '18 at 21:45

You can remove the quote characters from org-emphasis-regexp-components as described by @Malabarba in this blog post.

The relevant code from that post:

;; This HAS to come before (require 'org)
(setq org-emphasis-regexp-components
      '("     ('\"{“”"
        "-   .,!?;''“”\")}/\\“”"
        "    \r\n,"

See the doc string for org-emphasis-regexp-components: by default the quote characters are considered:

border - The chars forbidden as border characters.

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.