How can I make org-mode
markup work for a part of a word? For example, I'd like it to work for cases like this:
=Class=es
and this:
/Method/s
Based on my tests it seems like org-mode
markup syntax works on complete words only.
How can I make org-mode
markup work for a part of a word? For example, I'd like it to work for cases like this:
=Class=es
and this:
/Method/s
Based on my tests it seems like org-mode
markup syntax works on complete words only.
I don't think you can do it so that it shows up in the buffer as bold. If you just need it so that it appears bold when you export it to html, you can use:
th@<b>is is ha@</b>lf bold
org-mode
, the syntax for quoting HTML strings has changed. To get th<b>is is ha</b>lf bold
you'll have to write th@@html:<b>@@is is ha@@html:</b>@@lf bold
. –
Latinist GNU Emacs 25.2.2
. –
Nauplius These days, there is a way to do this (without using quoted HTML tags):
(setcar org-emphasis-regexp-components " \t('\"{[:alpha:]")
(setcar (nthcdr 1 org-emphasis-regexp-components) "[:alpha:]- \t.,:!?;'\")}\\")
(org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
The manual says that org-emphasis-regexp-components
can be used to
fine tune what characters are allowed before and after the markup characters [...].
It is a list containing five entries. The first entry lists characters that are allowed to immediately precede markup characters, and the second entry lists characters that are allowed to follow markup characters. By default, letters are not included in either one of these entries. So in order to successfully apply formatting to strings immediately preceded or followed by a letter, we have to add [:alpha:]
(which matches any letter) to both entries.
This is what the calls to setcar
do. The purpose of the third line is to rebuild the regular expression for emphasis based on the modified version of org-emphasis-regexp-components
.
setf
the car
and cadr
of org-emphasis-regexp-components
. –
Kerwinn org-set-emph-re
affects not only bold (* *
), but also italics (/ /
), underline (_ _
), and strikethrough (+ +
). Super nice! –
Kerwinn HiDPI: *Hi*gh *D*ots *P*er *I*nch
results in High Dots Per Inch where only the first and the last *
is matched.. org-mode version 9.5 –
Lalonde I don't think you can do it so that it shows up in the buffer as bold. If you just need it so that it appears bold when you export it to html, you can use:
th@<b>is is ha@</b>lf bold
org-mode
, the syntax for quoting HTML strings has changed. To get th<b>is is ha</b>lf bold
you'll have to write th@@html:<b>@@is is ha@@html:</b>@@lf bold
. –
Latinist GNU Emacs 25.2.2
. –
Nauplius A solution that has not been mentioned is to use a unicode zero width space (U+200B) in between the desired bolded and unbolded parts of a word.
To get the desired bolding of the word "Classes":
The word "Classes" should now have the desired appearance.
Note that there is the possibility that this will cause problems when exporting.
No, you can't do that. I searched for the same solution before and found nothing. A (very) bad hack is to do something like *Class* es (with a whitespace).
Perhaps you can write a short message to the creator, Carsten Dominik (Homepage), and ask him for a solution. He seems to be a nice guy.
org-mode
can be customized to apply markup to parts of words. See my answer below. –
Latinist src_latex{\textbf{Class}es and \textit{Method}s}
Building up on the previous excellent answer
I had to modify it a bit in order to make it work with spacemacs. Indeed, from the spacamacs org-layer documentation, available here, we can read
Because of autoloading, calling to org functions will trigger the loading up of the org shipped with emacs which will induce conflicts. One way to avoid conflict is to wrap your org config code in a with-eval-after-load block [...]
So, I put the following lines inside my dotspacemacs/user-config ()
(eval-after-load "org"
'(progn
(setcar org-emphasis-regexp-components " \t('\"{[:alpha:]")
(setcar (nthcdr 1 org-emphasis-regexp-components) "[:alpha:]- \t.,:!?;'\")}\\")
(org-set-emph-re 'org-emphasis-regexp-components org-emphasis-regexp-components)
))
As the accepted answer mentioned, it seems impossible to do this for current version of Orgmode, but here provides a workaround, so that very close to "emphasizing just parts of a word":
(*Class*)es
(*Method*)s
© 2022 - 2025 — McMap. All rights reserved.
\textbf{V}alence \texttt{Aware} Dictionary
Will print ony the "V" in bold-face, and the entire word "Aware" will appear in the org =verbatim= style. – Normalcy