196

Markdown allows ordered lists using numbers. How can I instead get an ordered list using letters? i.e.

A. the letter A
B. the letter B
C. etc

instead of

1. the number 1
2. the number 2
3. etc.
keflavich
  • 18,278
  • 20
  • 86
  • 118

7 Answers7

132

It doesn't appear that standard Markdown has this capability. You can:

  1. Use CSS, by putting this somewhere in your markdown document (note, this will effect all ordered lists in the document)
<style type="text/css">
    ol { list-style-type: upper-alpha; }
</style>
  1. Use an extended version of markdown. Pandoc markdown has a fancy_lists extension that will allow you to mark lists with letters and roman numerals.

Note: if using capital letters, two spaces are required before the text. See https://pandoc.org/MANUAL.html#fn1

A.  the letter A
A.  the letter B
A.  etc
Fuhrmanator
  • 11,459
  • 6
  • 62
  • 111
creativecoder
  • 1,631
  • 1
  • 13
  • 7
  • 44
    For those sticking to standard markdown, it may be helpful to add css rules like `ol ol { list-style-type: lower-alpha; }` and `ol ol ol { list-style-type: lower-roman; }` for different list styles at each level of nesting. – Justin Emery Jun 08 '15 at 16:35
  • 5
    Bitbucket uses HTML-safe standard markdown, so you really don't have any options. In this case, I just put the letter name after a bullet, like `* A. List item`. – James M. Lay Sep 08 '15 at 10:31
  • 4
    GitHub apparently also ignores `style` tags in `.md` files. – jacobq Mar 22 '16 at 23:27
  • 7
    :sigh: So if the solution is HTML, why the rush to Markdown and all its quirks? – Michael Scheper Nov 21 '16 at 18:35
  • 4
    @MichaelScheper Markdown's pretty great, it just has a few weird features like rudely ignoring the numbers you entered and choosing its own. – endolith Feb 07 '17 at 03:53
  • I can't put code ```js code ``` inside a
      tag in markdown, apparently :(
    – Alexander Mills Jun 01 '17 at 20:40
  • Markdown coexists with HTML. I find having a style block covers formatting issues like lettered lists quite well. – vj1 Sep 18 '20 at 14:45
  • This won't auto-create next list item when I hit `` inside a markdown list, right? – mahbubweb Oct 02 '20 at 10:48
  • This suggestion worked really well for me. Ended up assigning several levels: – Jeff82 Apr 28 '22 at 18:39
  • Didn't work in Jupyter-lab for me. – markling Apr 12 '23 at 09:36
67

Markdown itself cannot do that, but since you can put HTML in it, this provides a pretty simple way to do it:

<ol type="a">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>

Some derivations on some platforms might interpret only a very strict subset of HTML. For example, StackOverflow doesn't support the type attribute. But Wikipedia's MediaWiki Markdown does, and the GitHub Wiki Markdown does too.

Community
  • 1
  • 1
Terry
  • 14,529
  • 13
  • 63
  • 88
  • 3
    The downside is that you cannot stick markdown into the list items :-( – Nay Mar 02 '17 at 15:04
  • 1
    @Nay Again depends on your processor. [pandoc 2.13 and FatDown allow it](https://johnmacfarlane.net/babelmark2/?text=%3Col+type%3D%22a%22%3E%0A++%3Cli%3E**Coffee**%3C%2Fli%3E%0A++%3Cli%3ETea%3C%2Fli%3E%0A++%3Cli%3EMilk+test+**test**+%3C%2Fli%3E%0A%3C%2Fol%3E). I had not heard of [Fatdown](https://s9etextformatter.readthedocs.io/Bundles/Fatdown/) before, so there's a link to it. – ruffin Apr 30 '21 at 21:03
31

At least for recent versions of Pandoc (I'm using version 1.13.1), it looks like you can use some of the fancy_list syntax without having to enable the extension, e.g.:

I.  One                                                                                                                                                                                        
    A.  two                                                                                                                                                                                    
        1. three                                                                                                                                                                               
        2. four                                                                                                                                                                                
            i.  five                                                                                                                                                                           
            ii.  six                                                                                                                                                                           
                - seven                                                                                                                                                                        
                    * eight                                                                                                                                                                    
II.  Nine

To compile this into a PDF you can then run:

pandoc input.md -o output.pdf

NOTE: For this to work, you have to make sure you add an extra space after any letters or roman numerals: instead of the usual one space between a bullet and the text, use two instead. (see pandoc docs under "Extension: fancy_lists")

shir
  • 51
  • 6
Keith Hughitt
  • 4,860
  • 5
  • 49
  • 54
  • You can also use automatic numbering with this method too, e.g. `1. item 1, 1. item 2,` will automatically figure out which number needs to be used – Ben Mar 25 '22 at 16:14
22

Late to the party, but this might help other people looking for an R Markdown solution.

In R Markdown it's straight forward. The following minimal example lists.rmd shows different types:

---
title: "Lists"
output: pdf_document
---

A list with bullet points:

- Something
- Something else

A numeric list:

1. Something
1. Something else

A list using small letters:

a) Something
a) Something else

A list using capital letters:

A) Something
A) Something else

This knits to:

enter image description here

symbolrush
  • 7,123
  • 1
  • 39
  • 67
9

There's really no way to do this on most platforms -- GitHub, Slack, SO, BitBucket. (Source: A. This comment discussion B. You can try it.)

I suppose a regrettable workaround would be like this:

Sample MarkDown (RAW/EDIT MODE)

## My awesome list
- A. First option.
- **B.** Second option with bold.

Sample MarkDown (PREVIEW MODE)

My awesome list

  • A. First option.
  • B. Second option with bold.
om-ha
  • 3,102
  • 24
  • 37
2

To do indent formatting this is what I use:

<style type="text/css">
   /* Indent Formatting */
   /* Format: a-1-i-A-1-I */
   ol {list-style-type: lower-alpha;}
   ol ol { list-style-type: decimal;}
   ol ol ol { list-style-type: lower-roman;}
   ol ol ol ol { list-style-type: upper-alpha;}
   ol ol ol ol ol { list-style-type: decimal;}
   ol ol ol ol ol ol { list-style-type: upper-roman;}
   /* https://www.w3schools.com/cssref/pr_list-style-type.asp */
   /* https://stackoverflow.com/questions/11445453/css-set-li-indent */
   /* https://stackoverflow.com/questions/13366820/how-do-you-make-lettered-lists-using-markdown */
</style> 

Links at bottom to where I sourced the information. And Format is explained on the second line.

2

To add on the accepted answer, one can use the style attribute instead of or in situations where one cannot use the <style> tag.


<ol style="list-style-type: upper-alpha">
<li>the letter A</li>
<li>the letter B</li>
<li>etc</li>
</ol>

Markdown is not a replacement for HTML, or even close to it. Its syntax is very small, corresponding only to a very small subset of HTML tags. The idea is not to create a syntax that makes it easier to insert HTML tags. In my opinion, HTML tags are already easy to insert. The idea for Markdown is to make it easy to read, write, and edit prose. HTML is a publishing format; Markdown is a writing format. Thus, Markdown’s formatting syntax only addresses issues that can be conveyed in plain text.

For any markup that is not covered by Markdown’s syntax, you simply use HTML itself. There’s no need to preface it or delimit it to indicate that you’re switching from Markdown to HTML; you just use the tags.

The only restrictions are that block-level HTML elements — e.g. <div>, <table>, <pre>, <p>, etc. — must be separated from surrounding content by blank lines, and the start and end tags of the block should not be indented with tabs or spaces. Markdown is smart enough not to add extra (unwanted) <p> tags around HTML block-level tags.

Inline HTML, Daring Fireball: Markdown Syntax Documentation

rdela
  • 467
  • 4
  • 12