Tuesday, 17 September 2013

LaTeX: Itemize and Enumerate

Previously, we talk about paragraph, spacing, and indentation. What about listing in $\mathrm{\LaTeX}$?

Just like MS Word, $\mathrm{\LaTeX}$ has both bullet and alphanumeric environment for listing. Bullet listing is constructed inside the itemize domain. For example,

The codes above generate list with sublists. The outer list uses bullet for entries (Line 5 and Line 14) while the sublists (Line 7-12 and Line 16-20) use hyphen. The itemize domain can have up to three nested lists, each with a particular character for entries. Here is something worth to explore,

This returns Output 1, the first list with entries Line 5-6 uses bullets, then a sublist under Line 6 with two entries (Line 8-9) uses hyphen, another subsublist uses asterisk, and further down to subsubsublist, dot or period is utilize. If we go further to the fourth nested list we get error that says, "Too deeply nested".
Nested Itemize Error in Texmaker
For alphanumeric characters, the enumerate environment is used. Just like itemize, enumerate is limited to three nested lists. And has the following characters for four levels of listing: 1., (a), i., and A. Here is an example,

If you notice, there is not much difference between these codes and the previous one, we only replace the itemize with enumerate. With changes made, however, different outputs induced. Output 1 compiled from previous code for itemize and Output 2 from enumerate domain.
Output 1
Output 2

I hope you are not aware of the spacing in the codes above, the reason why we need to indent these, is for readability. It is always a good practice to indent the codes, usually four spaces. The final products as we witness, are indented. This is not of course the effect of the indentation in the codes, remember that $\mathrm{\LaTeX}$ ignores white spaces.

enumerate has a  package that offers more functions for manipulating the domain. For example, the demo we have previously, starts with numeric characters for the first list and roman number for the second nested list. What about if we want our list not in numeric form but rather in roman, how is that? Or what about if we want it to have A-1, A-2, $\cdots$, or Boy-A, Boy-B, $\cdots$. Things like that can be done using the enumerate package. Try this,

Now we want to start the enumeration at 5 or 21 or any number not 1. How is that? Well, we use \setcounter{enumi}{starting_number-1}, enumi is short for enumerate. Here is an example that starts at v (five),

Another type of listing is the description environment (reference here). Try this

This gives us Output 3; the description of the three distributions are originally from Wikipedia.

Output 3
 More on $\mathrm{\LaTeX}$ list structure is available here.

No comments:

Post a Comment