My question concerns org-mode. I'm trying to add the characters [ and ] to the org-emphasis-regexp-components in order to mark up words between square brackets. So I get for example the following effect:

[/bla bla/] → [/bla bla/]

I also want to export it to LaTeX.

I've already tried the solutions described bellow, but without success:

Inline verbatim and code with quotes in Org-mode



I can't understand what I'm doing wrong. I would appreciate your help. Thank you.

  • This morning, having had some rest, I did some more tests to find out what's going wrong. I got the markup working inside square brackets only in alliance with the "part of a word" markup as described here. In other words, when I simply add the characters [ and ] to the org-emphasis-regexp-components code it doesn't work (actually all markup features go crazy). But when I add [ and ] plus [:alpha:] it works perfectly, displayed on screen as well as on LaTeX export. Why? – gabrielpdp1979 Apr 20 '18 at 8:16
  • Maybe it's related to the fact that [ and ] are used in org to delimit links? – Vladimir Alexiev Apr 25 '18 at 11:31
  • The org-emphasis-regexp-components variable consists of multiple parts. Presumably you're adding [ to pre and ] to post. Where are you putting [:alpha:]? – glucas Apr 25 '18 at 15:34
  • @glucas Yes, I'm adding the brackets exactly as you presume. As for the [:alpha:], I'm puting it both to pre and post markup characters. I didn't try other combinations. As I said, it works, but it's a little annoying, so I enable the feature only for some specific export jobs, otherwise I just keep the default settings. That's all until now. – gabrielpdp1979 Apr 25 '18 at 19:19
  • Maybe you're right… But I can't see all that conflict in using square brackets both as links delimiters and as pre and post markup characters... – gabrielpdp1979 Apr 25 '18 at 19:22
  • Try this workaround using #+MACRO:

    #+MACRO: sbem  @@latex:[\emph{$1}]@@
    {{{sbem(blah blah)}}}

    When exported to LaTeX the macro is replaced with:

    [\emph{blah blah}]

This code was tested using:
emacs version: GNU Emacs 25.2.1 (x86_64-unknown-cygwin, GTK+ Version 3.22.10)
Org mode version: 9.1.2


Here's what I have in my config for this:

(with-eval-after-load 'org
  ; chars for prematch
  (setcar org-emphasis-regexp-components            "     ('\"{“”\[\\") 
  ; chars for postmatch
  (setcar (nthcdr 1 org-emphasis-regexp-components) "\] -   .,!?;:''“”\")}/\\“”") 
  ; forbidden chars
  (setcar (nthcdr 2 org-emphasis-regexp-components) "    \t\r\n,\"")
  ; body
  (setcar (nthcdr 3 org-emphasis-regexp-components) ".")
  ; max newlines 
  (setcar (nthcdr 4 org-emphasis-regexp-components) 1)
  (org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components))

Per this stack exchange discussion.

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.