| Getting Started Common Elements
Mechanics Technical Text Special Pages Special Documents
Creating Graphics Programming Miscellaneous Help and Recommendations Appendices |
Convenient and predictable list formatting is one of the many advantages of using LaTeX. Users of WYSIWYG word processors can sometimes be frustrated by the software's attempts to determine when they intend lists to begin and end. As a mark-up language, LaTeX gives more control over the structure and content of lists.
Lists often appear in documents, especially academic, as their purpose is often to present information in a clear and concise fashion. List structures in LaTeX are simply environments which essentially come in three types:
All lists follow the basic format:
\begin{list_type}\item{The first item}\item The second item\item The third etc\ldots\end{list_type} |
All three of these types of lists can have multiple paragraphs per item: just type the additional paragraphs in the normal way, with a blank line between each. So long as they are still contained within the enclosing environment, they will automatically be indented to follow underneath their item.Item content could be in the curly brackets for reading convenience of long items.
Try out the examples below, to see what the lists look like in areal document.
LaTeX will happily allow you to insert a list environment into anexisting one (up to a depth of four, more levels are availableusing packages). Simply begin the appropriate environment at thedesired point within the current list. Latex will sort out thelayout and any numbering for you.
\begin{enumerate}\item The first item\begin{enumerate}\item Nested item 1\item Nested item 2\end{enumerate}\item The second item\item The third etc\ldots\end{enumerate} |
Sometimes you feel the need to better align the different listitems. If you are using a KOMA-script class (or packagescrextend), thelabeling environment is handy. It takes a mandatoryargument that contains the longest of your labels.
\documentclass[twocolumn]{article}\usepackage{blindtext}\usepackage{scrextend}\addtokomafont{labelinglabel}{\sffamily}\begin{document}\blindtext\begin{labeling}{alligator}\item [ant] really busy all the time\item [chimp] likes bananas\item [alligator] very dangerous animal, sharp teeth, longmuscular tail and a bit of text that is longer than oneline and shows the alignment of text quite nicely\end{labeling}\end{document} |
If you are on tight space limitations and only have short itemdescriptions, you may want to have the list inline. Please notethat the example also shows how to change the font.
\documentclass[twocolumn]{article}\usepackage{blindtext}\usepackage[inline]{enumitem}\usepackage{xcolor}\begin{document}\blindtext Coco likes fruit. Her favorites are:\begin{enumerate*}[label={\alph*)},font={\color{red!50!black}\bfseries}]\item bananas\item apples\item oranges and\item lemons.\end{enumerate*}\blindtext\end{document} |
If you want a horizontal list, packagetasks can be handy. Incombination with a package like exsheets, you can prepare exampapers for students.
\documentclass[12pt]{article}\usepackage{tasks}\usepackage{exsheets}\SetupExSheets[question]{type=exam}\begin{document}\begin{question}Which one of the entries does not fit with the others?\begin{tasks}(4)\task mercury\task iron\task lead\task zinc\end{tasks}\end{question}\settasks{label=(\roman*),label-width=4ex}\begin{question}What is a funkyton?\begin{tasks}(2)\task A dancing electron\task A dancing proton\task A dancing neutron\task A Dixie Dancing Duck\end{tasks}\end{question}\end{document} |
When dealing with lists containing just a few words per item,the standard lists often take up too much space. Packageenumitem provides you a simple interface tocustomize the appearance of lists.
You can change the appearance of lists globally in the preamble,or just for single lists using the optional argument of theenvironment. Have a look at the following example where the liston the right is more compact usingnoitemsep.
\documentclass[twocolumn]{article}\usepackage{blindtext}\usepackage{enumitem}\begin{document}\blindtext\begin{itemize}\item more work\item more responsibility\item more satisfaction\end{itemize}\blindtext\newpage\blindtext\begin{itemize}[noitemsep]\item more work\item more responsibility\item more satisfaction\end{itemize}\blindtext\end{document} |
An example for alignment and the width of the label.
\documentclass[twocolumn]{article}\usepackage{blindtext}\usepackage{enumitem}\begin{document}\blindtext Coco likes fruit. Her favourites are:\begin{description}[align=left]\item [Kate] some detail\item [Christina]some detail\item [Laura]some detail\end{description}\begin{description}[align=right]\item [Kate] some detail\item [Christina]some detail\item [Laura]some detail\end{description}\begin{description}[align=right,labelwidth=3cm]\item [Kate] some detail\item [Christina]some detail\item [Laura]some detail\end{description}\blindtext\end{document} |
The documentation of packageenumitem goes into more detail withrespect to what can be changed and how. You can even define yourown lists.Environments likelabeling andtasks can be changed differently, details can be found in the package documentation respectively.
Theeasylist package allows you to create list using a more convenient syntax and with infinite nested levels.It is also very customizable.
Load the package with the control character as optional argument:
\usepackage[ampersand]{easylist} |
Theeasylist environment will default to enumerations.
\begin{easylist}& Main item~:&& Sub item.&& Another sub item.\end{easylist} |
It features predefined styles which you can set as optional argument.
\begin{easylist}[itemize]% ...\end{easylist} |
Available styles:
You can customize lists with the\ListProperties(...) command and revert back the customization with\NewList. Yes, that's parentheses for\ListProperties parameters.
TheStyle parameter sets the style of counters and text, theStyle* parameter sets the style of counters, and theStyle** parameter sets the style of text. The parameterNumbers determines the way that the numbers are displayed and the possible values arer orR (for lower and upper case Roman numerals),l orL (for lower and upper case letters),a (for Arabic numbers, the default), andz (for Zapf's Dingbats).
TheFinalMark parameter sets the punctuation of the final counter (Ex:FinalMark3={)}) whileFinalSpace sets the amount of space between the item and the item's text. TheMargin parameter sets the distance from the left margin (Ex:FinalSpace2=1cm). TheProgressive parameter sets the distance from the left margin of all items in proportion to their level.
TheHide = n parameter prevents the firstn counters from appearing in all levels. If there is a number after a parameter (Ex:Style3*) then this numbers indicates the level that it will affect (Ex:Style3=\color{red}).
Example of custom enumerate:
\begin{easylist}[enumerate]\ListProperties(Style2*=,Numbers=a,Numbers1=R,FinalMark={)})& Main item~:&& Sub item.&& Another sub item.\end{easylist} |
Note that we put theFinalMark argument between{} to avoid LaTeX understanding it as the end of the properties list.Now we change the default properties to print a custom itemize:
\usepackage{amssymb}\ListProperties(Hide=100, Hang=true, Progressive=3ex, Style*=-- ,Style2*=$\bullet$ ,Style3*=$\circ$ ,Style4*=\tiny$\blacksquare$ )% ...\begin{easylist}& Blah& Blah&& Blah&&& Blah&&&& Blah&&&&& Blah\end{easylist} | – Blah |
Spaces inStyle parameters are important. TheStyle* parameter acts as a default value andeasylist will use a medium dash for level 1, 5 and onward.
You can also define custom styles using LaTeX macros:
\newcommand\myitemize{\ListProperties(Hide=100, Hang=true, Progressive=3ex, Style*=$\star$ )}\newcommand\myenumerate{\ListProperties(Space=2\baselineskip)}% ...\begin{easylist}\myitemize& Blah\end{easylist} |
Important note:easylist has some drawbacks.First if you need to put an easylist inside an environment using the same control character as the one specified for easylist, you may get an error.To circumvent it, use the following commands provided by easylist:
\Activate\begin{easylist}& ...\end{easylist}\Deactivate |
Besides usingeasylist along with figures may cause some trouble to the layout and the indentation.LaTeX lists do not have this problem.
To use easylist with Beamer, each frame that uses easylist must be marked as fragile:
\begin{frame}[fragile]...\begin{easylist}[itemize]...\end{easylist}...\end{frame} |
| Previous: Fonts | Index | Next: Special Characters |