2

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

https://stackoverflow.com/questions/1218238/how-to-make-part-of-a-word-bold-in-org-mode

https://stackoverflow.com/questions/24169333/how-can-i-emphasize-or-verbatim-quote-a-comma-in-org-mode

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

5
  • 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? Apr 20, 2018 at 8:16
  • Maybe it's related to the fact that [ and ] are used in org to delimit links? Apr 25, 2018 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, 2018 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. Apr 25, 2018 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... Apr 25, 2018 at 19:22

2 Answers 2

1
  • 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

1

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 and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.