Use `org-extra-emphasis’ , when you need more Emphasis Markers in Emacs Org mode


Use org-extra-emphasis library, when you need more Emphasis Markers in Emacs Org mode

(or)

How to produce

Geronimo Stilton-esque Books

with Emacs Org mode

Limitations of emphasis markers in Emacs Org mode

Emacs Org mode provides following limited set of emphasis markers*, /, _, =, ~, + — for typesetting a span of text(1). These sets of Emphasis markers are sufficient for producing academic text.

However, there are times when you need to go beyond these limited set of emphasis markers.

For example, consider books like Geronimo Stilton.

These series of children’s books are produced in eye-catching colors and highlight important words in the text with illustrative typefaces.

Here is a sample page from the book “Bollywood Burglary”.

indian-food

How do you produce above richer text with Emacs Org mode?

A simple count on the above image shows that you need as much as 9 emphasis markers, and each type of emphasis calls for a different font, size, width etc.

So, the question now is

Can you produce Geronimo Stilton-esque text using Emacs Org mode?

The answer is

“Yes” … if you use the library org-extra-emphasis!

What does the library org-extra-emphasis do?

org-extra-emphasis provides following 16 numbers of additional emphasis markers.

!!, !@, !%, !&, @!, @@, @%, @&, %!, %@, %%, %&, &!, &@, &%, &&

These extra emphasis markers are mapped to 16 different faces: org-extra-emphasis-01, org-extra-emphasis-02, …, org-extra-emphasis-16.

As with native emphasis markers, when you use these extra emphasis markers in your Org mode file,

  • the text in your Emacs buffer gets highlighted.
  • a HTML or ODT export of the file reflects the emphasis.

It is easier to understand org-extra-emphasis with an example.

Demo of org-extra-emphasis

 

Step 1: Download org-extra-emphasis.el

Step 2: Install some fancy fonts

The demo uses following fonts.

  • CherryBomb
  • Eater
  • Diplomata
  • Linux Biolinum Keyboard O
  • Finger Paint
  • Fuzzy Bubbles
  • Gloria Hallelujah
  • Henny Penny
  • Humor Sans

Some of these fonts are available in Debian; the rest can be
downloaded from Google Fonts.

Step 3: Add the following setup code to user-init-file and restart Emacs.

(load-file "~/src/org-extra-emphasis/org-extra-emphasis.el")

;; Uncomment the following line if you are using the enhanced ODT exporter
;; https://github.com/kjambunathan/org-mode-ox-odt.

(load-file "~/.emacs.d/elpa/ox-odt-9.5.3.470/ox-odt.el")

(custom-set-faces
 '(org-default ((t ( 
                    :background "#fff8ca"
                    :inherit default
                    ))))
 '(org-extra-emphasis ((t ( 
                           :background "#fff8ca"
                           :height 1.5
                           :inherit default
                           :weight bold
                           :width normal
                           ))))
 '(org-extra-emphasis-01 ((t ( 
                              :family "CherryBomb"
                              :foreground "#A53E2D"
                              :inherit org-extra-emphasis
                              :underline t
                              ))))
 '(org-extra-emphasis-02 ((t ( 
                              :family "Eater"
                              :foreground "#EEB97E"
                              :inherit org-extra-emphasis
                              :weight heavy
                              ))))
 '(org-extra-emphasis-03 ((t ( 
                              :family "Diplomata"
                              :foreground "#683231"
                              :inherit org-extra-emphasis
                              ))))
 '(org-extra-emphasis-04 ((t ( 
                              :family "Linux Biolinum Keyboard O"
                              :foreground "#353D8B"
                              :inherit org-extra-emphasis
                              ))))
 '(org-extra-emphasis-05 ((t ( 
                              :family "Finger Paint"
                              :foreground "#54436E"
                              :inherit org-extra-emphasis
                              ))))
 '(org-extra-emphasis-06 ((t ( 
                              :family "Fuzzy Bubbles"
                              :foreground "#D65D8F"
                              :inherit org-extra-emphasis
                              ))))
 '(org-extra-emphasis-07 ((t ( 
                              :family "Gloria Hallelujah"
                              :foreground "#E5C494"
                              :inherit org-extra-emphasis
                              :weight extra-bold
                              ))))
 '(org-extra-emphasis-08 ((t ( 
                              :family "Henny Penny"
                              :foreground "#0B9FCF"
                              :inherit org-extra-emphasis
                              ))))
 '(org-extra-emphasis-09 ((t ( 
                              :family "Humor Sans"
                              :foreground "#C9564C"
                              :inherit org-extra-emphasis
                              )))))

Step 4: Create a file that uses extra emphasis markers

Create a file, say indian-food.org, with following content.

Remember, to reload the file in to Emacs with M-x revert-buffer. This is so that file local settings— buffer-face-mode and org-hide-emphasis-markers — take effect.

In the image below, pay attention to the extra emphasis markers, and how they are typeset.

#+odt_prettify_xml:

#+HTML_HEAD: <style>
#+HTML_HEAD: .textbox { color: #000000; background: #fff8ca; border: 1px solid #000000; padding: 1em;  }
#+HTML_HEAD: </style>

#+begin_textbox
#+begin_center
!!INDIAN FOOD!!
#+end_center

\\

Indian cuisine includes a wide assortment of colors, aromas and
!@flavors!@.

Food from India's northern region is non-vegetarian and less spicy,
using more diary products in dishes. The cuisine of the southern
regions is mostly vegetarian and tends to be !%spicier!%.

Dishes are often flavored with !&SPICES!& like turmeric, coriander,
cumin and tamarind, also known as the "Indian date."

Rice is a staple food of India, and it is served hot as a side
dish. When cooked in broth and flavored with spices, it's called
@%Pilau@%.  When served with chicken, lamb, or vegetables, it's called
@@BIRYANI@@.

Bread is also an essential staple, especially in north.  There are
many varieties of bread.  The most widespread in India is @%ROTI@% (also
known as @&CHAPATI@&), an unleavened round bread made with whole-wheat
flour.

%!DAL%! is typical Indian dish that is creamy and made with lentils and
various spices.  There are many types of %!DAL%!.
#+end_textbox

# Local Variables:
# eval: (buffer-face-mode 1)
# org-hide-emphasis-markers: t
# End:

Step 5: How the file is rendered in Emacs

indian-food-emacs

Step 6: Export to HTML with C-c C-e h o

Export above file to HTML with C-c C-e h o. This is how the HTML file looks like in Firefox.

indian-food-firefox

Conclusion

org-extra-emphasis is a very useful library.

The extra emphasis markers exports well not only to HTML, but also to ODT, if you are using the enhanced ODT exporter.  However, it does not export well to the LaTeX backend.

In this article, the extra emphais markers were used for typesetting a range of text. However, its use need not be limited to just typesetting. It could be used for any special handling of a chunk of text.

In the context of OpenDocument-format / LibreOffice, you can use these extra emphasis markers

  • to create index entries like concept index, author index etc
  • to mark a span of text as using a specific language like English, Tamil etc. These language hints can be used by the the spell-checker for locating a suitable dictionary.

Btw, if you haven’t already noticed, org-extra-emphasis need not be used in conjunction with document production. You can use this library for note taking as well. The extra emphasis markers are no different from physical markers that you use for highlighting text
in a physical textbook. You can use the extra emphasis markers as custom highlighters to guide your attention while composing or revising text.

Categories gnu

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close