Documente Academic
Documente Profesional
Documente Cultură
Abstract
In this article, which is part of the third chapter of our forthcoming book A LATEX Companion, we
take a look at LATEXs list environments. First the various parameters and commands controlling the
standard LATEX lists, enumerate, itemize, and description, are discussed. Then the general
list environment is introduced and we tell you how to build custom layouts by varying the values
of the parameters controlling this environment.
c Addison-Wesley
1993
CN Division, CERN, CH1211 Gen`eve 23, Switzerland, <goossens@cernvm.cern.ch>
y LAT X3 Project Coordinator, Zedernweg 62, D55128 Mainz, Germany,
E
<Mittelbach@mzdmza.zdv.Uni-Mainz.de>
z ISO, 1, rue de Varembe, CH1211 Gen`eve 20, Switzerland, <samarin@isocs.iso.ch>
Dutch TEX Users Group (NTG), P.O. Box 394, 1740 AJ Schagen, The Netherlands Reprint MAPS#11 (93.2); Nov 1993
178 Customizing LATEX lists Bijlage F
Appendix A: LATEX Overview for Style Writers \p@enumii, etc., respectively. The last three rows
A review of how to handle and manipulate the basic in the table show the command, its default definition,
LATEX programming structures, followed by a dis- and an example for the representation of references. It
cussion of the extensions introduced by the calc is important that you are careful to take into account
style in the field of arithmetic operations, and the the definitions of both the representation and reference
ifthen style for control constructs. building commands to get the references correct.
Appendix B: TEX Archive Sites
We can now create several kinds of numbered descrip-
An explanation of how to get the files described in
tion lists simply by applying what we have just learned.
our book (and other LATEX related software) from
the various TEX archives. Our first example redefines the first, and second level
An annotated bibliography of twelve pages. counters to use capital Roman digits and Latin char-
An index of over thirty pages. acters. The visual representation should be the value
of the counter followed by a dot. The default value
LATEX is presently being rewritten under the coordin- of table 1 is used for the reference prefix command
ation of one of the authors (Frank Mittelbach), Chris \p@enumi.
Rowley and Rainer Schopf. This endeavor is called the
\makeatletter
LATEX3 Project (see e.g., the previous MAPS, pages 95 \renewcommand{\theenumi}{\Roman{enumi}}
99). A lot of the functionality described in the Com- \renewcommand{\labelenumi}{\theenumi.}
panion as extensions to basic LATEX will be available \renewcommand{\theenumii}{\Alph{enumii}}
in that system: as part of the kernel, or in one of the \renewcommand{\labelenumii}{\theenumii.}
\renewcommand{\p@enumii}{\theenumi.}
extension styles. To help funding, half of the royalties \makeatother
from our book will go directly to the LATEX3 Project. \begin{enumerate} \item \textbf{Introduction }
Therefore, when buying it, you not only obtain a handy, \begin{enumerate}
complete, and up-to-date reference to many important \item \textbf{Applications} \newline
Motivation for research and applications
and useful packages available with LATEX today, but you related to the subject. \label{q1}
also actively contribute to making LATEX more powerful \item \textbf{Organization} \newline
and user-friendly in the future. Explain organization of the report, what
is included, and what is not. \label{q2}
\end{enumerate}
1 Modifying LATEX Lists \item \textbf{Literature Survey} \label{q3}
\item \textbf{Proposed Research} \label{q4}
Lists are a very general LATEX construct and are used \end{enumerate}
to build many of LATEXs display-like environments. q1=\ref{q1} q2=\ref{q2} q3=\ref{q3} q4=\ref{q4}
LATEXs standard list environments: enumerate,
itemize, and description are discussed in the
I. Introduction
next section, where we also show how they can be cus-
tomized. The general list environment is discussed in A. Applications
section 2. Motivation for research and applications
It is relatively easy to customize the three standard related to the subject.
LATEX list environments, and the three sections below B. Organization
will look at each of these environments in turn. Changes Explain organization of the report, what is
to the default definitions of these environments can be included, and what is not.
made globally by redefining certain list defining para-
meters in the document preamble, or they can be kept II. Literature Survey
local. III. Proposed Research
Reprint MAPS#11 (93.2); Nov 1993 Dutch TEX Users Group (NTG), P.O. Box 394, 1740 AJ Schagen, The Netherlands
Bijlage F Customizing LATEX lists 179
I. text inside list, more text inside list, text inside the counter using (respectively) the \Alph, \alph,
list, \Roman, \roman, or \arabic styles.
II. text inside list, more text inside list, text inside Moreover, these letters can be surrounded by any strings
list, involving any other TEX expressions; however the
tokens A, a, I, i, or 1 must be specified inside a {}
III. text inside list, more text inside list, text inside group if they are not to be taken literally.
list, more text inside list.
The cross-reference commands \label, and \ref
w1=I w2=II can be used as with the standard enumerate envir-
onment. Note, however, that with this style the \ref
You might even want to select different markers for con- command only produces the chosen representation of
secutive labels. For instance, in the following example, the counter valuenot the whole label. It prints the
characters from the PostScript font ZapfDingbats are value in the same style as \item, as determined by the
used. In this case there is no straightforward way presence of one of the tokens A, a, I, i, or 1 in the
for automatically making the \ref commands pro- optional argument.
duce the correct references. You can, however, use
the dingautolist environment defined in the minor \begin{enumerate}[EX i.]
\item text item one level one.
style file nfpi, which is part of the PSNFSS system. More text item one level one \label{LA}
Note also that we have used the calc style for doing \item text item two level one.
the addition inside the \setcounter command. \begin{enumerate}[{example} a)]
\item text item one level two.
\newcounter{local}\renewcommand{\labelenumi} More text item one level two \label{LB}
{\setcounter{local}{171+\value{enumi}}% \item text item two level two.
\ding{\value{local}}} \end{enumerate}
\begin{enumerate} \end{enumerate}
\item text inside list, more text inside list, \begin{enumerate}[{A}-1]
text inside list, more text inside list; \item text item one level one for list two.
\item text inside list, more text inside list, \label{LC}
text inside list, more text inside list; \item text item two level one for list two.
\item text inside list, more text inside list, \end{enumerate}
text inside list, more text inside list. This is how list entries are referenced:
\end{enumerate} \ref{LA}, \ref{LB} and \ref{LC} or
more fully EX\ref{LA}. and A-\ref{LC}.
text inside list, more text inside list, text inside This example generates the following output:
list, more text inside list; EX i. text item one level one. More text item one level
text inside list, more text inside list, text inside one
list, more text inside list; EX ii. text item two level one.
text inside list, more text inside list, text inside example a) text item one level two. More text
list, more text inside list. item one level two
example b) text item two level two.
Finally, for those who do not want to get involved in
customizing these commands themselves, there exists a
A-1 text item one level one for list two.
minor style enumerate (by David Carlisle), which re-
defines the enumerate environment with an optional A-2 text item two level one for list two.
argument specifying the style in which the counter has
to be printed. This argument can contain any one of This is how list entries are referenced: i, ii.a and 1
the tokens A, a, I, i, or 1 for typesetting the value of or more fully EX i. and A-1.
Dutch TEX Users Group (NTG), P.O. Box 394, 1740 AJ Schagen, The Netherlands Reprint MAPS#11 (93.2); Nov 1993
180 Customizing LATEX lists Bijlage F
1.2 Customizing an itemize List The standard LATEX styles set the starting point of
For a simple unnumbered itemize list, the labels are the label box in a description environment -
defined by the commands shown in table 2. \labelsep to the left of the left margin of the en-
closing environment, so that the \descriptionla-
To create a list with different labels, you can redefine the bel command in the example above first adds a value
label-generating command. You can make that change of \labelsep to start the label aligned with the left
local for one list, as in the example below, or you can margin.
make it global by putting the \labelitemi redefin-
ition in the document preamble. The following simple
list is a standard itemize list with a marker from the 2 Making Your Own Lists
PostScript ZapfDingbats font for the first level label: Lists are generated by the generic environment list:
\newenvironment{MYitemize}{%
\renewcommand{\labelitemi}{\ding{43}}%
\begin{list}{default label}{decls}
\begin{itemize}}{\end{itemize}} item list
\begin{MYitemize} \end{list}
\item Text of the first item in the list.
\item Text of the first sentence in the second
item of the list. And the second sentence. The parameter default label is the text to be used as a
\item This sentence in the text of the third label when an \item command is issued without an
item of the list.
optional argument. The parameter decls sets up the
\end{MYitemize}
different geometrical parameters of the list environ-
ment (see Fig. 1). That figure also shows the default
And this is the result: values for those parameters. The parameters can all be
redefined with the help of the \setlength or \ad-
Text of the first item in the list. dtolength commands.
Text of the first sentence in the second item of Several LATEX environments are defined with the help
the list. And the second sentence. of list (for example quote, quotation, center,
This sentence in the text of the third item of the flushleft, and flushright). Note that these
list. environments have only one item, and the \item[]
command is specified in the environment definition.
1.3 Customizing a description List As an example, we can consider the quote environ-
ment whose definition gives it the same left and right
Using the description environment you can
margins. The simple variant Quote, shown below, is
change the \descriptionlabel command that
identical to quote apart from the double quote sym-
generates the label. In the following example the font
bols added around the text. Note the special precau-
for typesetting the labels is changed from bold to sans
tions, which must be taken to eliminate undesirable
serif.
white space in front (\ignorespaces) and follow-
\renewcommand{\descriptionlabel}[1]%
ing (\unskip) the text.
{\hspace{\labelsep}\textsf{#1}}
\begin{description} \newenvironment{Quote}% Definition of Quote
\item[A.] text inside list, text inside list, {\begin{list}{}{%
text inside list, more text inside list; \setlength{\rightmargin}{\leftmargin}}
\item[B.] text inside list, text inside list, \item[]\ignorespaces}
text inside list, more text inside list; {\unskip\end{list}}
\item[C.] text inside list, text inside list, \ldots\ text before.
text inside list, more text inside list. \begin{Quote}
\end{description} Some quoted text, more quoted text.
Some quoted text, more quoted text.
\end{Quote}
The above gives: Text following \ldots
A. text inside list, text inside list, text inside list, more
text inside list; : : : text before.
B. text inside list, text inside list, text inside list, more
Some quoted text, more quoted text.
text inside list;
Some quoted text, more quoted text.
C. text inside list, text inside list, text inside list, more
text inside list. Text following : : :
Reprint MAPS#11 (93.2); Nov 1993 Dutch TEX Users Group (NTG), P.O. Box 394, 1740 AJ Schagen, The Netherlands
Bijlage F Customizing LATEX lists 181
6
\leftmargin
- ?Item 1
\listparindent \parsep
Paragraph 2
6\itemsep + \parsep
Label
?
Item 2
Dutch TEX Users Group (NTG), P.O. Box 394, 1740 AJ Schagen, The Netherlands Reprint MAPS#11 (93.2); Nov 1993
182 Customizing LATEX lists Bijlage F
General lists are often used for documenting computer the argument of the \makelabel command, and not
commands or program functions. For instance, in the to the argument of the outer environment.
following examples entry and its variants are used.
In each case the name of the topic being described is \newenvironment{Ventry}[1]%
{\begin{list}{}{%
entered as the parameter of the \item command. \renewcommand{\makelabel}[1]{%
In the list below, the \makelabel command and \textsf{##1:}\hfil}%
\settowidth{\labelwidth}{\textsf{#1:}}%
the two geometrical parameters (\labelwidth and \setlength{\leftmargin}{%
\leftmargin) are redefined.1 . \labelwidth+\labelsep}}}%
{\end{list}}
\newcommand{\entrylabel}[1]{%
\mbox{\textsf{#1:}}\hfil}
\newenvironment{entry}%
{\begin{list}{}{% Description: Returns from a function. If issued at
\renewcommand{\makelabel}{\entrylabel}% top-level, the interpreter simply ter-
\setlength{\labelwidth}{35pt}% minates, just as if end of input had
\setlength{\leftmargin}%
{\labelwidth+\labelsep}}}%
been reached.
{\end{list}}
Errors: None.
\begin{entry}
Return values: Any arguments in effect are passed
\item[Description]
Returns from a function. If issued at back to the caller.
top-level, the interpreter simply terminates,
just as if end of input had been reached.
\item[Errors] None.
However, several lists with varying widths for the label
\item[Return values]\mbox{}\\ field on the same page might look typographically un-
Any arguments in effect acceptable. Evaluating the width of the term is another
are passed back to the caller. possibility. If it is wider than \labelwidth, an ad-
\end{entry}
ditional empty box is appended with the effect that the
description part starts on a new line. This matches the
Description: Returns from a function. If issued at top- conventional method for displaying options in UNIX
level, the interpreter simply terminates, just manuals.
as if end of input had been reached.
\newlength{\Mylen}
Errors: None. \newcommand{\Lentrylabel}[1]%
Return values: {\settowidth{\Mylen}{\textsf{#1:}}%
\ifthenelse{\dimengreater{\Mylen}%
Any arguments in effect are passed back to {\labelwidth}}{\parbox[b]{\labelwidth}
the caller. % term > labelwidth
{\makebox[0pt][l]{\textsf{#1:}}
\mbox{}\\}}%
This example shows a typical problem with description- {\textsf{#1:}}
like lists when the text in the label (term) is wider than % text < labelwidth
the width of the label. Standard LATEX lets the text of \hfil\relax}
the term continue into the text of the description part. \newenvironment{Lentry}%
{\renewcommand{\entrylabel}%
This is normally not desired, and to improve the visual {\Lentrylabel}\begin{entry}}
appearance of the list we have started the description {\end{entry}}
part on the next line. A new line was forced by put-
\begin{Lentry}
ting an empty box on the same line, followed by \\
\item[Description] Returns from a function.
command. If issued at top-level, the interpreter
simply terminates, just as if end of
In the remaining part of this section various possibilit- input had been reached.
ies for controlling the width and mutual positioning of \item[Errors] None.
the term and description parts will be investigated. One \item[Return values] Any arguments in effect
method for accomplishing this is to change the width are passed back to the caller.
\end{Lentry}
of the label. The environment is declared with an ar-
gument specifying the desired width of the label field
(normally chosen to be the widest term entry). Note the As the last line in this example shows, the Lentry
redefinition of the \makelabel command where you environment is defined in terms of the entry environ-
specify how the label will be typeset. As this redefin- ment. The label generating command \entrylabel
ition is put inside the definition of the Ventry envir- is now replaced by the \Lentrylabel command.
onment, the argument placeholder character # must be The latter first sets the length variable \Mylen equal
escaped to ## to signal LATEX that you are referring to to the width of the label. It then compares that length
1
In this and some of the following examples, we have used the style files calc and ifthen
Reprint MAPS#11 (93.2); Nov 1993 Dutch TEX Users Group (NTG), P.O. Box 394, 1740 AJ Schagen, The Netherlands
Bijlage F Customizing LATEX lists 183
with \labelwidth. If the label is smaller than \la- are passed back to the caller.
belwidth, then it is typeset on the same line as the \end{Mentry}
description term, otherwise it is typeset in a zero width
box with the material sticking out to the right as far as De- Returns from a function. If issued at top-
needed (forcing a new line) so that the description term scrip- level, the interpreter simply terminates, just
starts one line lower. tion: as if end of input had been reached.
Dutch TEX Users Group (NTG), P.O. Box 394, 1740 AJ Schagen, The Netherlands Reprint MAPS#11 (93.2); Nov 1993