Introductions
I use unordered (or bulleted) lists frequently, particularly in documentation or creating labs. Recently, I’ve been using Quarto to draft labs for a GIS class I’ll be teaching next semester There’s lots of bulleted lists and screen shots. I find getting screen shots in bulleted lists the way I want them is tricky. Lists can have “tight” or “loose” spacing. I like tight lists and prefer the images indented. This post explores list formatting. What works best is to have the screen shot as a sub-list item (Section 2.4). Provided one just uses RStudio’s source editor, it is even possible to get captions and figure numbers (Figure 2) to work in a tight list.
Markdown Lists
For all examples that follow, source is on the left output is on the right.
Tight list with no images
- List item 1
- List item 2
- List item 3
- Sub-list item
- Another sub-list item
- List item 4
- List item 1
- List item 2
- List item 3
- Sub-list item
- Another sub-list item
- List item 4
There is space after the sub-list. I don’t presently understand why but I can live with it.
Image inline no spaces
- List item 1
- List item 2
![](dog.png)
- List item 3
- Sub-list item
- Another sub-list item
- List item 4
- List item 1
- List item 2
- List item 3
- Sub-list item
- Another sub-list item
- List item 4
This gets interpreted and rendered as though it were written as
- List item 1
- List item 2 ![](dog.png)
- List item 3
- Sub-list item
- Another sub-list item
- List item 4
Image inline with four spaces
From SO, I got the idea of indenting the image four spaces. However, to do that one must put a space between the last list item and the image. Just as above, without the blank line it gets rendered as though it were written like the last example. Note that the sub-list is tight. This is because there are no extra lines between list items in this two item sub-list.
- List item 1
- List item 2
![](dog.png)
- List item 3
- Sub-list item
- Another sub-list item
- List item 4
- List item 1
- List item 2
- List item 3
- Sub-list item
- Another sub-list item
- List item 4
With at least one blank line the image is rendered in the list. However, the list is “loose” which I don’t care for.
- List item 1
- List item 2
![](dog.png)
- List item 3
- Sub-list item
- Another sub-list item
- List item 4
List item 1
List item 2
List item 3
- Sub-list item
- Another sub-list item
List item 4
Regardless of implementation, if you want “tight” lists, the only way to always get that is to never include any blank lines anywhere in your list items.
— @Waylan’s answer on SO
So it seems…
Image in a sub-list no caption or figure annotations
For now, my solution is to put the images into a sub-list item. I’m not enamored with having a bullet next to the image, but it might be a benefit if there was more than one screenshot needed.
- List item 1
- List item 2
- ![](dog.png)
- List item 3
- Sub-list item
- Another sub-list item
- List item 4
- List item 1
- List item 2
- List item 3
- Sub-list item
- Another sub-list item
- List item 4
Useul Resources
- markdown, can you insert image inbetween ordered list items? - Stack Overflow
- Why when creating unordered lists `-` (ul li elements) sometimes with p element is created but not all the time? · quarto-dev/quarto-cli · Discussion #5096
- Extra lines appearing between list items in Github Markdown - Stack Overflow
Citation
@online{craig2023,
author = {Craig, Nathan},
title = {Tight {Markdown} {Lists} with {Images}},
date = {2023-11-16},
url = {https://ncraig.netlify.app/posts/2023-11-16-tight-markdown-lists-w-images/index.html},
langid = {en},
abstract = {This post looks at the outcome of various ways of
formatting bulleted lists with inline images. These are issues one
might consider when putting screen shots into documentation that is
organized as a series of steps in an unordered or ordered markdown
list.}
}