TransWikia.com

Styling lists in org-export (html)

Emacs Asked by user2699 on March 5, 2021

So, for variety’s sake I’d like lists and sublists to have different styles. In emacs, I’ve enabled org-list-allow-alphabetical, but this doesn’t work with export (not a bug). However, there doesn’t seem to be any simple way to change styles without adding extensive latex or html code to the file.

For example, with a list like this,

1. Parent
   1. child

I’d like to use a different marker for the sublist, to avoid confusion, eg

1. Parent
   a) child

Latex seems to do this rather well by default. Is there a way to specify it for other exporters?

One Answer

The html output from the exporter is just nested ol lists without any labels. To alter the labels you can use CSS:

#+HTML_HEAD: <style type="text/css">
#+HTML_HEAD:  ol ol { list-style-type: lower-alpha; }
#+HTML_HEAD: </style>

  1. first
  2. second
     a. sub
     b. under
  3. third

Sample output

To change the fullstops after the labels to something else see https://stackoverflow.com/q/5945161/4050592 for appropriate CSS.

Note that you can use the #+ATTR_HTML to add specific attributes to elements including a list. This way you can make specific styling, such as:

#+HTML_HEAD: <style type="text/css">
#+HTML_HEAD:  ol#al { list-style-type: upper-alpha; }
#+HTML_HEAD: </style>

#+ATTR_HTML: :id al
  1. first
  2. second
  3. third

Styled sample

Correct answer by Andrew Swann on March 5, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP