Chapter 14 Lists
Lists are important in lots of contexts, and the desire to nest lists has led to some very, very complex discussions on the PreTeXt email lists. We’ll keep it simple here. There are a variety of places that lists can live, but a good mental model is that a list must be put inside an element that’s similar to
<p>
. So for example, you can’t put your list directly inside a <subsection>
, but instead must wrap the list in a <p>
.
There are two common types of lists: ordered and unordered. (There’s also the description list. See Section 4.11 for more information.) As in HTML, an ordered list is produced with
<ol>
and an unordered list with <ul>
. The items of your list are structured inside <li>
tags. The example in Listing 14.0.1 shows that these <li>
tags can contain a paragraph in a <p>
tag but you do not need to. If you’re just putting a sentence or two inside your <li>
, no <p>
is required. However, if you also want to put an image or more complicated items inside the <li>
, then the <li>
must be structured with <p>
by placing “loose” text inside one or more <p>
.The code in Listing 14.0.1 produces the following output:
- First item.
- Second item, showing can wrap content with
p
.
You can use the
@marker
attribute 1 on the <ol>
tag to change the default markers. For instance, if the opening tag for the list above were <ol marker="A">
, then the list items would be marked as A. and B. Sensible things to use with @marker
are i, I, A, a, and 1. Nesting of lists is possible, and there are sensible default markers. The code in Listing 14.0.2 produces the following output:
- First item.
- Another item.
You can also use the
@cols
attribute to split a list (ordered or unordered) across multiple columns if the screen/page is suitably wide. The value of this attribute must be an integer between 2 and 6 (inclusive).As illustrated here, an attribute is something that appears between the < and > of the opening tag. The convention in XML usage is to prefix an attribute name with
@
when referring to the attribute outside of the tag. You do not use the @
in the tag itself.