Org mode lets you monospace text by enclosing it within = signs. However, I don't think the regex actually considers if it is a "starting" = or a "closing" =.

Example: =s[=$i$=]= renders not only the s[ and ] as monospace, but also the enclosed $i$, which is not what I want. Another example:

In =bar=s case, blabla, =something monospaced=

This monospaces not only bar and something monospaced, but also the text within, i.e. s case, blablabla,. I have to insert a space between =bar= and the following s, but this is not something I want to do. Any help?

  • Check out org-emphasis-regexp-components and be prepared for some amount of pain. Also do a search for the variable here (e.g. this answer might be useful). And certainly read the doc string of the variable in emacs: C-h v org-emphasis-regexp-components RET.
    – NickD
    Jan 2, 2020 at 16:15

1 Answer 1


Please refer to this answer for all the gory details.

The default post set of characters in org-emphasis-regexp-components is -[:space:].,:!?;'\")}\\[ i.e. dash, the :space: character class, period, comma, colon, exclamation mark, question mark, semicolon, single quote, double quote, closing paren, closing brace, backslash or opening square bracket. Any of those after a closing emphasis character (= in your examples above) will mark the end of the emphasis region.

In your case, you want to add the dollar sign $ to the post set, but you also want to add it to the pre set: that way, the example =s[=$i$=]= will work as you want it to work. For the other example, you want s (or perhaps any alpha char) to be in the post set. So in your init file, define org-emphasis-regexp-components as follows (and make sure that it is defined before you load Org mode):

(setq org-emphasis-regexp-components


(require 'org)


This makes your examples work, but depending on your needs, it might not be enough or it might be too much: you might need to add additional characters or classes to the pre and/or post sets, but you might also find that different examples require conflicting definitions, in which case you might be stuck: this variable might be too blunt an instrument to resolve some situations.

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.