Mark-up for bold and italic in emacs org-mode
Asked Answered
T

3

13

In emacs org-mode, we can use mark-ups to set Emphasis and monospace.
e.g.

*bold*

/italic/

How can we make a word both bold and italic?
It seems neither */.../* nor /*...*/ works.

Turbulence answered 10/6, 2015 at 7:3 Comment(0)
R
18

In fact, both of these do work.

/*test*/

exports to HTML as

<i><b>test</b></i>

*/test/* works similarly. LaTeX / PDF export also works as you expect.

Org itself doesn't fontify both the bold and italic, but the semantics are fine.

Renayrenckens answered 10/6, 2015 at 11:34 Comment(3)
Thanks for your answer. I am using Emacs in Windows (as GUI). In org-mode, I can hide the markup symbols and see the effect of bold and italic by (setq org-hide-emphasis-markers t). But when I use both, only the outer markup takes effect.Turbulence
@dzhu, yes, that's what I said. Emacs doesn't fontify italics with bold but the semantics are correct, as you can see when exporting.Renayrenckens
@Renayrenckens with some gymnastics org can fontify multiple markups, see my answer belowFellah
F
5

Expanding on @Chris answer covering semantics being there, if you're interested in visible fontification effect inside your org notes, you have three approaches:

Highlight parts of your text

enter image description here

Nesting works nicely as long as you don't need to start / end two tags at once.

Use multiple tags with escape symbols

The closest you can get is

fontification emacs

The code is: *\ /\ _\ ~fontification can be nested~\_\/\*

So you need \​​ ​ (backslash and space) to escape following opening tags and \ (backslash) to escape following closing tags.

The need for space is annoying, and in it looks like this when exported to html: fontification html

So yes, you can have multiple mark-ups at once, but you have to choose between seeing the effect in emacs or having it nicely formated on export.

Modify how markup looks in emacs

Alternatively you could change how mark-up looks in emacs without modyfing exporting format, i.e. to make bold look red you'd need this:

(add-to-list 'org-emphasis-alist
         '("*" (:foreground "red")
           ))

as covered in this great question and answer.

Fellah answered 20/3, 2017 at 2:47 Comment(0)
F
1

The near-seamless way to get such markup highlighted in Emacs is by using zero-width spaces and joiners, specifically

/<joiner><space>*<text>*<space><joiner>/
*<joiner><space>/<text>/<space><joiner>*

where:

  • <joiner> is the ZERO WIDTH JOINER (U+200D) [or any non-whitespace(?)]
  • <space> is the ZERO WIDTH SPACE (U+200B) [or any whitespace]

I suspect wrapping <text> in <joiner><space>...<space><joiner> will make the inner markup more robust but it's usually not needed and gets in the way so this is good enough.

Factorize answered 9/5, 2024 at 13:52 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.