% Prevent infinite loops \def\LaTeXo{\LaTeX~2.09} \let\Otemize =\itemize \let\Onumerate =\enumerate \let\Oescription =\description % Zero the vertical spacing parameters \def\Nospacing{\itemsep=0pt\topsep=0pt\partopsep=0pt\parskip=0pt\parsep=0pt} % Redefine the environments in terms of the original values \newenvironment{Itemize}{\Otemize\Nospacing}{\endlist} \newenvironment{Enumerate}{\Onumerate\Nospacing}{\endlist} \newenvironment{Description}{\Oescription\Nospacing}{\endlist} \makeatletter \input b-conv.sty \let\origverbatim\verbatim \def\verbatim{\par\@verbatim\small \frenchspacing\@vobeyspaces\verbatim@start} \makeatother \def\AmS{{\protect\the\textfont2 A}\kern-.1667em\lower .5ex\hbox{\protect\the\textfont2 M}\kern -.125em{\protect\the\textfont2 S}} \renewcommand{\AmSLaTeX}{\mbox{\AmS-\LaTeX}} \renewcommand{\meta}[1]{$\langle$\itshape #1\/$\rangle$} \renewcommand{\labelitemi}{{\bfseries --}} \title{\LaTeXe{}, an overview} \author[Michel Goossens]{Michel Goossens\\CN Division, CERN, CH1211 Gen\\lq\nobreak{}eve 23, Switzerland\\ \texttt{goossens@cern.ch}} \begin{Article} \begin{abstract} This article gives an overview of the new or extended user commands available with \LaTeXe, the new \LaTeX{} release, compared to the previous version \LaTeXo. After introducing the new preamble commands, the extensions for defining new commands and environments, and handling length and boxes are discussed. The new font selection commands are explained, both for text and math, and it is shown how to easily use different font families. A list of supported class and package files is given and new possibilities for controlling page contents and floats are discussed. Most of this material is described in much greater detail in \lq\lq\nobreak{}The \LaTeX{} Companion\rq\rq\nobreak{}~\cite{bib-Companion} and in the second edition of the \LaTeX{} Reference Manual~\cite{bib-Lamport}. \end{abstract} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Why \LaTeXe?} \LaTeX{} became generally available in 1986; its popularity has increased ever since, and many extensions have been developed. Unluckily, these extensions were included in incompatible formats, \eg \lq\lq\nobreak{}standard\rq\rq\nobreak{} \LaTeX{} with and without \NFSS{}, \SliTeX, \AmSLaTeX, and so on. From the \LaTeX{} source alone, it was difficult to determine for which of these (or other) formats a document was composed and, because different sites could have different configuration, document portability was a problem. Already in 1989 at the Stanford TUG Conference Frank Mittelbach and Rainer Sch\"opf got together with Leslie Lamport to discuss these (and other) topics and they published their ideas about possible ways to evolve \LaTeX{} in TUGBoat~\cite{Mittelbach:TB10-3-400-401,Mittelbach:TB11-3-337-345}. This lead a few years later to the start of the long-term \LaTeX3 project \cite{Mittelbach:TB13-1-96-101,Rowley:TB13-3-390-391,% Mittelbach:TB13-4-510-515,Mittelbach:TTN3-1-7-11}. However, to help end the confusion for the present \LaTeX{} users, after a meeting in Spring 1993 between Leslie Lamport and Frank Mittelbach in Mainz, it was decided to release an upgraded version of \LaTeX, called \LaTeXe{}, which was officially announced in August 1993 at the TUG Conference at Aston. Its stated aims are: \begin{Itemize} \item bring all extensions back under a single format; \item prevent proliferation of mutually incompatible dialects of \LaTeXo{}; \item \NFSS{} becomes the \lq\lq\nobreak{}standard\rq\rq\nobreak{} font selection scheme; \item make style files like \textsf{amstex} (formerly \AmSLaTeX{} format) or \textsf{slides} (formerly \SliTeX{} format) into extension packages, all using the same base format; \item add a small number of often-requested features; \item retain the \lq\lq\nobreak{}touch and feel\rq\rq\nobreak{}, or the \lq\lq\nobreak{}flavour\rq\rq\nobreak{} of \LaTeXo{}. \end{Itemize} The first beta version of \LaTeXe{} was released at the end of 1993, while the first production release is foreseen for \lq\lq\nobreak{}Spring 1994\rq\rq\nobreak{}. After that, twice a year (in \lq\lq\nobreak{}Spring\rq\rq\nobreak{} and \lq\lq\nobreak{}Autumn\rq\rq\nobreak{}) consolidation releases are planned, in order to keep all versions of the files in synchronization. Bug reports are handled centrally by inviting the users to fill out an electronic form, distributed with the \LaTeXe{} distribution, and sending it via electronic mail to \Lit{latex-bugs@rus.uni-stuttgart.de}. Note that only bug reports referring to the last two releases will be considered. You can also subscribe to the \LaTeXe{} discussion list on \Lit{LATEX-2E@DHDURZ1.BITNET} and post questions (and answers) to that list. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Initial and preamble commands} In this section commands which can only be used before or in the preamble will be discussed. The first two below can only appear \emph{before} the \Lcs{documentclass} command. \subsection*{Initial commands} \BDefCmo{NeedsTeXFormat}{format-name}{release-date} This command, which is normally present in package and class files, can also be useful in user documents to make sure that the file is run with \LaTeXe. Users who try and run it with \LaTeXo{} or plain \TeX{} will get a reasonably clear error message. An example is \begin{verbatim} \NeedsTeXFormat{LaTeX2e}[1994/02/01] \end{verbatim} If you want to make sure that your document can be processed at another site, it could make sense that you include all packages and files that your document needs together with the main file. \LaTeXe{} provides the following syntax to facilitate this \begin{BDef} \DefEm{filecontents}{file-name} \\ \qquad \meta{file-contents} \\ \LEND{filecontents} \end{BDef} When your document file is run through \LaTeXe{} the body of each \Lenv{filecontents} environment is written verbatim to a file whose name is given as the argument \Larg{file-name}. If a file with such a name already exists in any of the directories \lq\lq\nobreak{}visible\rq\rq\nobreak{} to \TeX{} only an informative message is given, the body of the environment is by-passed, and the file is not replaced. \subsection*{Preamble commands} The next commands in the preamble are specifically designed to differentiate \LaTeXe{} documents from those needing \LaTeXo{}. \BDefComo{documentclass}{option-list}{class-name}{release-date} This command or \lq\lq\nobreak{}declaration\rq\rq\nobreak{} replaces the \LaTeXo{} command \Lcs{documentstyle}. There must be exactly one \Lcs{documentclass} declaration in a document, and it must come first (except for the \lq\lq\nobreak{}initial\rq\rq\nobreak{} commands described above). \noindent \Larg{option-list}: list of options that each can modify the formatting of document elements defined in the \Larg{class-name} file or in packages loaded with \Lcs{usepackage} declarations, as described below. \noindent \Larg{class-name}: name of the class file (file extension \Lfn{cls}). \noindent \Larg{release-date} (optional) specifies release date of the class file, using the format \Lit{YYYY/MM/DD}. If a version of the class older than this date is found, a warning is issued. \BDefComo{documentstyle}{option-list}{style-name}{release-date} This command, which is supported for compatibility reasons, is similar to \Lcs{documentclass}, but it loads a \lq\lq\nobreak{}compatibility mode\rq\rq\nobreak{} which redefines certain commands to act as they did in \LaTeXo{} and thus allows you to run your old files unchanged through \LaTeXe. Note, however, that in this mode, you \emph{cannot} use any of the \LaTeXe{} extensions described in this article. You can define new or change existing document elements by loading package files with \Lcs{usepackage}, whose syntax is: \BDefComo{usepackage}{option-list}{package-name}{release-date} \noindent \Larg{package-name}: name of the package (file extension \Lfn{sty}); a package can \begin{Itemize} \item define new document elements; \item modify elements defined in the class file; \item extend the range of documents that can be processed. \end{Itemize} \noindent \Larg{option-list}: list of options, each of which can modify the formatting of elements defined in the package. \noindent \Larg{release-date}: (optional) earliest desired release date of package file (see \Lcs{documentclass} command above). Any number of\ \Lcs{usepackage} are allowed, but \LaTeXe{} makes sure that each package is only loaded once. On top of processing the list of options specified in the argument \Larg{option-list} on its \Lcs{usepackage} command, each package also processes the option \Larg{option-list} on the \Lcs{documentclass} command. \BDefC{listfiles} To help you get an overview of the files read in by your document during processing, you can place a \Lcs{listfiles} command in the preamble of your document. This will display the list of all files used at the end of the run. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection*{Example of document preambles} The following preamble references the \Lclass{article} class with the (global) options \Loption{twocolumn} and \Loption{a4paper}, and loads the \Lpack{multicol} and \Lpack{babel} packages, the latter with the \Loption{german} and \Loption{french} options. Other document parameters (\eg the \Lit{textheight}) can also be specified. \begin{verbatim} \documentclass[twocolumn,a4paper]{article} \usepackage{multicol} \usepackage[german,french]{babel} \addtolength{\textheight}{2cm} \begin{document} ... \end{document} \end{verbatim} The following shows three equivalent ways of specifying the loading of packages. \begin{verbatim} \documentclass[german]{book} \usepackage[german]{babel} \usepackage[german]{varioref} \usepackage{multicol} \usepackage{epic} \end{verbatim} Somewhat less verbose is: \begin{verbatim} \documentclass[german]{book} \usepackage[german]{babel,varioref} \usepackage{multicol,epic} \end{verbatim} With \Loption{german} as global option you can write: \begin{verbatim} \documentclass[a4paper,german]{book} \usepackage{babel,varioref,multicol,epic} \end{verbatim} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% A complex document might look something like the following: \begin{verbatim} \NeedsTeXFormat{LaTeX2e}[1994/05/01] \begin{filecontents}{varioref.sty} .... % Code for varioref package \end{filecontents} \listfiles % print list of files referenced \documentclass[a4paper,german]{book} % book class \usepackage{varioref} \begin{document} %--------------------- front matter of document \maketitle \section*{...} % e.g. section named "Preface" \tableofcontents % chapter with table of contents \listoffigures % chapter with list of figures \listoftables % chapter with list of tables %--------------------- body of the document \part{...} \chapter{...} \section{...} \chapter{...} \part{...} %--------------------- back matter of document \appendix \chapter{...} % chapters labelled appendix \chapter{...} \begin{thebibliography} ... % bibliography entries \end{thebibliography} \begin{theindex} ... % index entries \end{theindex} \end{document} \end{verbatim} Note that, to ensure that the recipient of the document can process the file correctly, the code of the \Lpack{varioref} package is shipped with the file inside a \Lenv{filecontents} environment. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Option processing} Options that are specified in the \Larg{option-list} argument of the \Lcs{documentclass} or \Lcs{usepackage} commands are handled as follows: \begin{Enumerate} \item They are first divided into two types, \emph{local} and \emph{global}: \begin{Itemize} \item for a \emph{class}, the options from its \Lcs{documentclass} command are local and there are no global options; \item for a \emph{package}, the options from its \Lcs{usepackage} command are local but the options from the \Lcs{documentclass} command are global. \end{Itemize} \item The local and global options that have been declared within the current class or package are processed first, normally in their order of declarations, thus their order in \Larg{option-list} is irrelevant. \item Any local options not declared in the current class or package are then processed. For document classes, this usually means that they are ignored, except for this fact being recorded by adding the option to a list of \lq\lq\nobreak{}unused options\rq\rq\nobreak{}; they may, of course, be used later since they become global options for every package subsequently loaded. For packages, usually an error message is produced, giving the choice of retyping the option name in case it is incorrect. \end{Enumerate} Finally, when the \LBEG{document} command is reached \LaTeXe{} will produce a list of all global options not used by the class or any package file, and issue a warning message for each. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Defining new commands and environments} This section and the following describe commands and environments that are used inside the document body (\ie after the \LBEG{document}) command. Let us first look at what is available for defining new commands and environments. \subsection*{Defining commands} Commands are defined or redefined in \LaTeX{} with: \begin{BDef} \Lcs{newcommand}\Largb{\bs{}mycom}\Largs{narg}\Largs{default}\texttt{\%}\\ \phantom{\Lcs{newcommand}}\Largb{command definition}\\[1mm] \Lcs{renewcommand}\Largb{\bs{}mycom}\Largs{narg}\Largs{default}\texttt{\%}\\ \phantom{\Lcs{renewcommand}}\Largb{command definition}\\[1mm] \Lcs{providecommand}\Largb{\bs{}mycom}\Largs{narg}\Largs{default}\texttt{\%}\\ \phantom{\Lcs{providecommand}}\Largb{command definition} \end{BDef} The first and second commands show enhancements with respect to \LaTeXo{} by providing the possibility to have an \emph{optional} argument when (re)defining a user command. If there is a second optional parameter to \Lcs{newcommand}, etc., then the command being defined has an optional parameter, with \Larg{default} value if not specified The last form is useful for general purpose files that are included in a document and over which the user does not always have control (\eg \BibTeX{} databases). If \Lcs{mycom} is not yet defined, the \Lcs{providecommand} will act as \Lcs{newcommand} and define it, otherwise the existing definition is kept. The number of arguments, which \emph{includes} the optional argument, is in the range \Lit{0\(\le\)\Larg{narg}\(\le\)9}. If the command has no arguments, then the \Lit{[0]} can be omitted. Inside the \textit{command definition} part, the arguments are referenced as \Lit{#1} to \Lit{#\Larg{narg}}, the optional argument, if present, being the first one. For example, compare the following commands, with no, one mandatory, one optional, and one optional and one mandatory argument, allowing the user more freedom in each case. \begin{verbatim} \newcommand{\seq}{x_{0},\ldots\,x_{n}} \newcommand{\seqm}[1]{#1_{0},\ldots\,#1_{n}} \newcommand{\seqo}[1][k]{x_{0},\ldots\,x_{#1}} \newcommand{\seqom}[2][k]{#2_{0},\ldots\,#2_{#1}} $$\seq\quad\seqm{z}$$ $$\seqo\quad\seqo[l]$$ $$\seqom{y}\quad\seqom[i]{q}$$ \end{verbatim} This gives: \newcommand{\seq}{x_{0},\ldots\,x_{n}} \newcommand{\seqm}[1]{#1_{0},\ldots\,#1_{n}} \newcommand{\seqo}[1][k]{x_{0},\ldots\,x_{#1}} \newcommand{\seqom}[2][k]{#2_{0},\ldots\,#2_{#1}} $$\seq\quad\seqm{z}$$ $$\seqo\quad\seqo[l]$$ $$\seqom{y}\quad\seqom[i]{q}$$ If a command should work both in math and in text mode, special care should be taken in its definition. In \LaTeXe{} you have the following command: \BDefCm{ensuremath}{math code} As its name implies \Lmcs{ensuremath} ensures that its argument is always typeset in math mode by surrounding it if necessary with \Lit{$} signs. For instance, the above can be rewritten as: \begin{verbatim} \renewcommand{\seq}{\ensuremath{x_{0},\ldots\,x_{n}}} \renewcommand{\seqm}[1]{% \ensuremath{#1_{0},\ldots\,#1_{n}}} \seq,\quad\seqm{z} or $\seq,\quad\seqm{z}$ \end{verbatim} \renewcommand{\seq}{\ensuremath{x_{0},\ldots\,x_{n}}} \renewcommand{\seqm}[1]{\ensuremath{#1_{0},\ldots\,#1_{n}}} \seq,\quad\seqm{z} or $\seq,\quad\seqm{z}$ \subsection*{Defining New Environments} In \LaTeXo{}, environments are defined or redefined with the commands: \begin{BDef} \DefCmomm{newenvironment}{name}{narg}{begdef}{enddef} \\ \DefCmomm{renewenvironment}{name}{narg}{begdef}{enddef} \end{BDef} The number of arguments is in the range \Lit{0\(\le\)\Larg{narg}\(\le\)9}; and, in the case of no parameters, you can omit \Lit{[0]}. Inside the definition part, \Larg{begdef}, these parameters are referenced as \Lit{#1} to \Lit{#\Larg{narg}}. If arguments are present, then they are defined when \emph{entering} the environment by specifying them on the command \verb=\begin{myenv}= as shown below. \begin{BDef} \LBEG{myenv}\lcb\Larg{arg\(_1\)}\rcb\Lit{...}\lcb\Larg{arg\(_{\mathrm{k}}\)}\rcb \end{BDef} When \emph{exiting} an environment with the command \verb=\end{myenv}= no parameters can be specified. Moreover, the parameters specified with the \verb=\begin{myenv}= command when entering the environment (see above) are no longer available in the definition part \Larg{enddef} where you define the actions which should take place when leaving the \Larg{myenv} environment. As with commands, in \LaTeXe{} you can now also define environments with an optional (first) argument. \begin{BDef} \Lcs{newenvironment}\Largb{myenv}\Largs{narg}\Largs{default}\texttt{\%}\\ \phantom{\Lcs{newenvironment}}\Largb{begdef}\Largb{enddef} \end{BDef} The default for the optional argument is given between the second pair of square brackets \Largs{default}. Inside the \Larg{begdef} part, which is executed when the environment \Larg{myenv} is entered, the optional argument can be accessed with \Lit{#1}, while the mandatory arguments (when present) are addressed as \Lit{#2} to \Lit{#\Larg{narg}}. When the \Larg{myenv} environment is used without an optional parameter, \Lit{#1} will contain the string specified as \Largs{default}. As an example, a variant, \Lmenv{deflist}, of a \Lenv{description} environment will be constructed. The \Lmenv{deflist} environment behaves somewhat like a standard \LaTeX{} \Lenv{description} environment if it is used without an optional argument. If an optional argument is specified, then the width of the description label will be put equal to the width of the argument. Thus, by specifying the widest entry in the list as an optional argument, you ensure that the description parts of all entries line up nicely. The result below first shows the (default) behaviour of the \Lenv{deflist} list and then what it looks like when using the optional argument. \begin{verbatim} \newenvironment{deflist}[1][\quad]% {\begin{list}{}{ \renewcommand{\makelabel}[1]{\textbf{##1}\hfil}% \settowidth{\labelwidth}{\textbf{#1}}% \setlength{\leftmargin}{\labelwidth+\labelsep}}} {\end{list}} \begin{deflist} \item[First] This is a short term. \item[Long term] This is a long term. \item[Even longer term] A very long term. \end{deflist} \begin{deflist}[Even longer term] ..... \end{deflist} \end{verbatim} \newenvironment{deflist}[1][\quad]% {\begin{list}{}{% \renewcommand{\makelabel}[1]{\emph{##1}\hfil}% \settowidth{\labelwidth}{\emph{#1}}% \setlength{\leftmargin}{\labelwidth+\labelsep}}} {\end{list}} \begin{deflist} \item[First] This is a short term. \item[Long term] This is a long term. \item[Even longer term] A very long term. \end{deflist} \begin{deflist}[Even longer term] \item[First] This is a short term. \item[Long term] This is a long term. \item[Even longer term] A very long term. \end{deflist} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Playing with lengths} Lengths can be defined, set and changed by the following commands. \begin{BDef} \DefCm{newlength}{cmd} & \qquad \DefCmm{setlength}{cmd}{len}\\ \DefCmm{addtolength}{cmd}{len}\\ \DefCmm{settowidth}{cmd}{text} & \qquad\Lcs{width}\\ \DefCmm{settoheight}{cmd}{text}& \qquad\Lcs{height}\\ \DefCmm{settodepth}{cmd}{text} & \qquad\Lcs{depth} \\ & \qquad\Lcs{totalheight} \end{BDef} The new \Lcs{settoheight} and \Lcs{settodepth} commands, in analogy with the \Lcs{settowidth} command, already present in \LaTeXo{}, allow one to \lq\lq\nobreak{}measure\rq\rq\nobreak{} the height and depth of some \TeX{} material. The lengths \Lcs{width}, \Lcs{height}, \Lcs{depth}, and \Lcs{totalheight} are also new in \LaTeXe{}, and can be used inside the box commands described in the next section. For ease of reference an overview of \TeX{}\rq\nobreak{}s units of length is given below. \begin{center} \small \def\pip{\vrule height 4 true pt } \begin{tabbing} \Lit{dd}\ \= xxx \kill% \hspace{.68\linewidth} \= xxx \kill \Lit{sp} \> scaled point (65536~sp = 1~pt) \TeX\rq\nobreak{}s smallest unit. \\ \Lit{pt} \> point = \(\frac{1}{72.27}\)~in = 0.351~mm \` \hbox to 1 pt{\pip\hrulefill\pip} \\ \Lit{bp} \> big point (72~bp = 1~in), also PostScript point \` \hbox to 1 bp{\pip\hrulefill\pip} \\ \Lit{dd} \> Did\^ot point \( = \frac{1}{72}\) of a French inch, \(= 0.376\)~mm \` \hbox to 1 dd{\pip\hrulefill\pip} \\ % \Lit{mm} \> millimeter = 2.845~pt \` \hbox to 1 mm {\pip\hrulefill\pip} \\ % \Lit{pc} \> pica = 12~pt = 4.218~mm \` \hbox to 1 pc{\pip\hrulefill\pip} \\ % \Lit{cc} \> cicero = 12~dd = 4.531~mm \` \hbox to 1 cc{\pip\hrulefill\pip} \\ % \Lit{cm} \> centimeter = 10~mm =2.371~pc \` \hbox to 1 cm{\pip\hrulefill\pip} \\ % \Lit{in} \> inch = 25.4~mm = 72.27~pt = 6.022~pc \` \hbox to 1 in{\pip\hrulefill\pip} \\ % \Lit{ex} \> height of a small \lq\lq\nobreak{}x\rq\rq\nobreak{} for the current font \` \hbox to 1 ex{\pip\hrulefill\pip} \\ % \Lit{em} \> width of capital \lq\lq\nobreak{}M\rq\rq\nobreak{} in current font \` \hbox to 1 em{\pip\hrulefill\pip} \\ % \Lit{mu} \> math mode unit (18~mu = 1~em) \` \hbox to .12em{\pip\hrulefill\pip} \\ % \end{tabbing} \end{center} The following lines show how length commands are created, defined, changed, and used. They work, most of the time, both for rigid and rubber lengths. \begin{verbatim} \newlength{\Mylen} Mylen = \the\Mylen \end{verbatim} \newlength{\Mylen} Mylen = \the\Mylen \begin{verbatim} \setlength{\Mylen}{10mm} Mylen = \the\Mylen \setlength{\Mylen}{5mm plus 1mm minus .5mm} \par Mylen = \the\Mylen % Use a rubber length \end{verbatim} \setlength{\Mylen}{10mm} Mylen = \the\Mylen \setlength{\Mylen}{5mm plus 1mm minus .5mm} \par Mylen = \the\Mylen % Use a rubber length \begin{verbatim} \setlength{\Mylen}{1em} One em is \the\Mylen; \addtolength{\Mylen}{1pc} add one pica \the\Mylen. \end{verbatim} \setlength{\Mylen}{1em} One em is \the\Mylen; \addtolength{\Mylen}{1pc} add one pica \the\Mylen. \begin{verbatim} \settowidth{\Mylen}{May} The width is \the\Mylen \settowidth{\Mylen}{\Large May} and now \the\Mylen. \settoheight{\Mylen}{May} The height is \the\Mylen \settoheight{\Mylen}{\Large May} and now \the\Mylen. \settodepth{\Mylen}{May} The depth is \the\Mylen \settodepth{\Mylen}{\Large May} and now \the\Mylen. \end{verbatim} \settowidth{\Mylen}{May} The width is \the\Mylen \settowidth{\Mylen}{\Large May} and now \the\Mylen. \settoheight{\Mylen}{May} The height is \the\Mylen \settoheight{\Mylen}{\Large May} and now \the\Mylen. \settodepth{\Mylen}{May} The depth is \the\Mylen \settodepth{\Mylen}{\Large May} and now \the\Mylen. \lq\lq\nobreak{}Rubber\rq\rq\nobreak{} (variable) lengths are very useful for placing information on the page. \begin{BDef} \Lmskip{fill} \end{BDef} This is a rubber length with a natural length of zero. It can stretch to any positive value and its value should not be changed! \BDefCm{stretch}{dec\_num} This is a more useful rubber length, since \Lmskip{fill} is equivalent to \Lit{\Lmcs{stretch}\lcb1\rcb}. More generally, \Lit{\Lmcs{stretch}\lcb\Larg{dec\_num}\rcb} has a stretchability of \Larg{dec\_num} times \Lmskip{fill}. It can be used to fine-tune the positioning of text horizontally or vertically. Examples of the use of these stretchable lengths for controlling the horizontal and vertical page layout are given below. \begin{verbatim} \newcommand{\HS}[1][1.]{\hspace{\stretch{#1}}} \begin{center} left \hfill right\\ left \HS[.5]\fbox{$\frac{1}{3}$}\hfill right\\ left \HS middle \hfill right\\ left \hrulefill\ middle \hrulefill\ right\\ left \dotfill\ right\\ left \dotfill\ \HS[.5] \dotfill\ right\\ left \dotfill\ \HS \dotfill\ right\\ left \dotfill\ \HS[2.] \dotfill\ right \end{center} \end{verbatim} \newcommand{\HS}[1][1.]{\hspace{\stretch{#1}}} \begin{center} left \hfill right\\ left \HS[.5]\fbox{$\frac{1}{3}$}\hfill right\\ left \HS middle \hfill right\\ left \hrulefill\ middle \hrulefill\ right\\ left \dotfill\ right\\ left \dotfill\ \HS[.5] \dotfill\ right\\ left \dotfill\ \HS \dotfill\ right\\ left \dotfill\ \HS[2.] \dotfill\ right \end{center} \begin{verbatim} \documentclass{article} \usepackage{times} \thispagestyle{empty} \newcommand{\HRule}{\rule{\linewidth}{1mm}} \setlength{\parindent}{0mm} \setlength{\parskip}{0mm} \begin{document} \vspace*{\stretch{1}} \HRule \begin{flushright} \Huge Geoffrey Chaucer\\[5mm] The Canterbury Tales \end{flushright} \HRule \vspace*{\stretch{2}} \begin{center} \Large\textsc{London 1400} \end{center} \end{document} \end{verbatim} \begin{center} \fbox{\epsfig{bbllx=90pt,bblly=160pt,bburx=520pt,bbury=720pt,% file=vspaceex.eps,height=9cm}} \end{center} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection*{Page Markup---Several Kinds of Boxes} Boxes are at the very heart of \TeX{}\rq\nobreak{}s basic typesetting paradigm, and \LaTeX{} provides several commands which make it easy to make use of this functionality. \begin{BDef} \DefCm{mbox}{text}\hspace*{1em}\DefCoom{makebox}{width}{pos}{text} \\ \DefCm{fbox}{text}\hspace*{1em}\DefCoom{framebox}{width}{pos}{text} \\ \end{BDef} In addition to centreing the text with positional argument \Lit{[c]} (the default), you can position the text flush left (\Lit{[l]}) or flush right (\Lit{[r]}). \LaTeXe{} also offers you an \Lit{[s]} specifier that will stretch your \Larg{text} from the left margin to the right margin of the box provided it contains some stretchable space. As already mentioned in the previous section, \LaTeXe{} also allows you to make use of four special length parameters inside the \Larg{width} argument of the box commands: \Lmdim{width}, \Lmdim{height}, \Lmdim{depth}, and \Lmdim{totalheight}. These parameters specify the natural size of the \Larg{text}, where \Lmdim{totalheight} is the sum of \Lmdim{height} and \Lmdim{depth}. The examples below show how these various parameters are used to control the layout in the box. Note that use is also made of the \Lpack{calc} package, which allows arithmetic operations in the arguments of the commands. \begin{verbatim} \framebox{A few words of advice} \par \framebox[\width + 6mm][s]{A few words of advice} \par \framebox[1.5\width]{A few words of advice} \end{verbatim} \framebox{A few words of advice} \par \framebox[\width + 6mm][s]{A few words of advice} \par \framebox[1.5\width]{A few words of advice} \BDefComm{rule}{lift}{width}{total\_height} Rules come in handy for controlling the height of a box. Together with the new \LaTeX{} commands for measuring the height and depth of your boxes, they allow you to perform micro-typographic adjustments for tuning the visual presentation of your document elements. \begin{verbatim} \newsavebox{\Maybox}\savebox{\Maybox}{\Large May} \newlength{\Mdp}\settodepth{\Mdp}{\usebox{\Maybox}} \newlength{\Mht}\settoheight{\Mht}{\usebox{\Maybox}} \addtolength{\Mht}{\Mdp} \framebox[1.6\width+1em][s]{\usebox{\Maybox}} \quad \framebox[1.6\width+1em][s]{\usebox{\Maybox}% \rule[-2\Mdp]{0mm}{2\Mht}} \end{verbatim} \newsavebox{\Maybox}\savebox{\Maybox}{\Large May} \newlength{\Mdp}\settodepth{\Mdp}{\usebox{\Maybox}} \newlength{\Mht}\settoheight{\Mht}{\usebox{\Maybox}} \addtolength{\Mht}{\Mdp} \framebox[1.6\width+1em][s]{\usebox{\Maybox}} \quad \framebox[1.6\width+1em][s]{\usebox{\Maybox}% \rule[-2\Mdp]{0mm}{2\Mht}} Zero-width boxes are also useful in other circumstances. \begin{verbatim} \begin{center} A centred sentence.\makebox[0cm][l]{$^{123}$}\\ Some more text in the middle. \\ \makebox[0cm][r]{$^{321}$}A centred sentence.\\ \end{center} \noindent\makebox[0cm][r]{\(\Leftrightarrow\)}% As seen in the margin of the current line, boxes with a vanishing width can stick out in the margin. \end{verbatim} \begin{center} A centred sentence.\makebox[0cm][l]{$^{123}$}\\ Some more text in the middle. \\ \makebox[0cm][r]{$^{321}$}A centred sentence.\\ \end{center} \noindent\makebox[0cm][r]{\(\Leftrightarrow\)}% As seen in the margin of the current line, boxes with a vanishing width can stick out in the margin. \subsection*{Moving boxes} Boxes can be moved up or down by the command: \BDefCmoom{raisebox}{lift}{depth}{height}{contents} The simple example below shows its principle of use. \begin{verbatim} \begin{flushleft} x111x \raisebox{-1ex}{downward} x222x \\ x333x \raisebox{1ex}{upward} x444x \\[1em] x111x \raisebox{-1ex}[0cm][0cm]{downward} x222x\\ x333x \raisebox{1ex}[0cm]{upward} x444x \end{flushleft} \end{verbatim} \begin{flushleft} x111x \raisebox{-1ex}{downward} x222x \\ x333x \raisebox{1ex}{upward} x444x \\[1em] x111x \raisebox{-1ex}[0cm][0cm]{downward} x222x\\ x333x \raisebox{1ex}[0cm]{upward} x444x \end{flushleft} A more useful example is the generation of text \lq\lq\nobreak{}between\rq\rq\nobreak{} two rows in a table (by \lq\lq\nobreak{}hiding\rq\rq\nobreak{} the boxes\rq\nobreak{} content from \TeX{}.) \begin{verbatim} \begin{center} \begin{tabular}{|c|c|c|} \hline & \multicolumn{2}{c|}{title}\\\cline{2-3} \raisebox{1.5ex}[0cm][0cm]{100} & A & B \\\hline 20000000 & 10 & 10 \\\hline \end{tabular} \end{center} \end{verbatim} \begin{center} \begin{tabular}{|c|c|c|} \hline & \multicolumn{2}{c|}{title}\\\cline{2-3} \raisebox{1.5ex}[0cm][0cm]{100} & A & B \\\hline 20000000 & 10 & 10 \\\hline \end{tabular} \end{center} Finally, when your printer driver allows it, you can rotate boxes. In this case the use of the various box dimension parameters becomes apparent. \begin{verbatim} \newcommand{\DoT}[1]{\begin{turn}{45}#1\end{turn}} x1 \DoT{\fbox{Not so Good.}} x2 \DoT{\raisebox{\depth}{\fbox{I like it.}}} x3 \DoT{\raisebox{-\height}{\fbox{Bad Choice.}}} x4 \end{verbatim} \bigskip \newcommand{\DoT}[1]{\begin{turn}{45}#1\end{turn}} x1 \DoT{\fbox{Not so Good.}} x2 \DoT{\raisebox{\depth}{\fbox{I like it.}}} x3 \DoT{\raisebox{-\height}{\fbox{Bad Choice.}}} x4 \subsection*{Placing parboxes and minipages} In \LaTeXo{}, boxes which can contain more than one paragraph are defined as follows. \begin{BDef} \DefComm{parbox}{pos}{width}{text} \\[1mm] \DefEom{minipage}{pos}{width} \\ \qquad\Larg{text} \\ \LmEND{minipage} \end{BDef} A simple example of its use is the following \begin{verbatim} \parbox{.3\linewidth}{This is the contents of the left-most parbox.} \hfill Centerline \hfill \parbox{.3\linewidth}{This is the right-most parbox. Note that the typeset text looks sloppy because \LaTeX{} cannot nicely balance the material in these narrow columns.} \end{verbatim} \parbox{.3\linewidth}{This is the contents of the left-most parbox.} \hfill Centerline \hfill \parbox{.3\linewidth}{This is the right-most parbox. Note that the typeset text looks sloppy because \LaTeX{} cannot nicely balance the material in these narrow columns.} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection*{Generalized parboxes and minipages} Sometimes it is helpful to predefine the vertical dimension of a paragraph box. For this \LaTeXe{} has additional optional arguments for \Lmenv{minipage} and \Lmcs{parbox}. \begin{BDef} \DefCooom{parbox}{pos}{height}{inner-pos}{width}\Largb{text} \\ \DefEooom{minipage}{pos}{height}{inner-pos}{width}\\ \qquad\Larg{text}\\ \LmEND{minipage} \end{BDef} The \Larg{inner-pos} determines the position of \Larg{text} within the box. It can be \Lit{t}, \Lit{c}, \Lit{b}, or \Lit{s}. If not specified, the value of \Larg{pos} will be used. You can think of \Larg{height} and \Larg{inner-pos} as the vertical equivalent of the \Larg{width} and \Larg{pos} arguments of a \Lcs{makebox}. If you use the \Lit{s} position the \Larg{text} will be vertically stretched to fill the given \Larg{height}. Thus, in this case you are responsible for providing vertically stretchable space if necessary using, for example, \Lcs{vspace} or \Lcs{vfill} commands. As with the other box commands you can use \Ldim{height}, \Ldim{totalheight}, and so on to refer to the natural dimensions of the box when specifying the optional argument. \begin{verbatim} xx \fbox{\parbox[b][1.5\height][s] {30mm}{Some text on top. \par\vfill In the middle. \par\vfill And a few lines on the bottom of the box.}} \fbox{\parbox[b][\height+\baselineskip][s] {30mm}{This time a few lines on the top of the box. But only one line \par\vfill down here.}} xx \end{verbatim} xx \fbox{\parbox[b][1.5\height][s] {30mm}{Some text on top. \par\vfill In the middle. \par\vfill And a few lines on the bottom of the box.}} \fbox{\parbox[b][\height+\baselineskip][s] {30mm}{This time a few lines on the top of the box. But only one line \par\vfill down here.}} xx %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection*{Manipulating Boxed Material} Material can be typeset once and then stored inside a named box, so that its contents can be retrieved later. \LaTeX{} offers the following commands for dealing with this situation. \begin{BDef} \DefCm{newsavebox}{cmd} & \quad declare box \\ \DefCmm{sbox}{cmd}{text} & \quad fill box \\ \DefCmoom{savebox}{cmd}{width}{pos}{text}& \quad fill box \\ \DefCm{usebox}{cmd} & \quad use contents\\[1mm] \DefEm{lrbox}{cmd} & \quad fill box \\ \qquad\Larg{text} \\ \LmEND{lrbox} \end{BDef} Note that the environment \Lenv{lrbox} is an addition in \LaTeXe{}. \Larg{cmd} should be a box register previously allocated with \Lmcs{newsavebox}. The environment \Lmenv{lrbox} will save \Larg{text} in this box for later use with \Lmcs{usebox}. Leading and trailing spaces are ignored. Thus, \Lmenv{lrbox} is basically the environment form of \Lmcs{sbox}. You can make good use of this environment if you want to save the body of some environment in a box for further processing. For example, the following code defines the environment \Lmenv{fminipage} that works like a \Lenv{minipage} but surrounds its body with a frame. Note the use of the optional argument for controlling the width of the boxed minipage, and the fact that verbatim material can be used inside. To be able to do the arithmetic operations you will also need to have the \Lpack{calc} package loaded. \begin{verbatim} \newsavebox{\fminibox} \newlength{\fminilength} \newenvironment{fminipage} [1][\linewidth]% default width is \linewidth {\setlength{\fminilength}% {#1-2\fboxsep-2\fboxrule}% \begin{lrbox}{\fminibox}% \begin{minipage}{\fminilength}} {\end{minipage}\end{lrbox}% \noindent\fbox{\usebox{\fminibox}}} \end{verbatim} \newsavebox{\fminibox} \newlength{\fminilength} \newenvironment{fminipage} [1][\linewidth]% default width is \linewidth {\setlength{\fminilength}% {#1-2\fboxsep-2\fboxrule}% \begin{lrbox}{\fminibox}% \begin{minipage}{\fminilength}} {\end{minipage}\end{lrbox}% \noindent\fbox{\usebox{\fminibox}}} \begin{verbatim} \begin{fminipage} In this environment verbatim text like \verb=\fminibox= can be used. \end{fminipage} \end{verbatim} \begin{fminipage} In this environment verbatim text like \verb=\fminibox= can be used. \end{fminipage} \begin{verbatim} \begin{fminipage}[.5\linewidth] .... \end{fminipage} \end{verbatim} \begin{fminipage}[.5\linewidth] In this environment verbatim text like \verb=\fminibox= can be used. \end{fminipage} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \subsection*{For hackers only: a list with two optional parameters} What if we want to define a command or environment with, \eg \emph{two} optional arguments? Suppose we want a list where we are able to specify not only the width of the label, but also whether the list should be \lq\lq\nobreak{}dense\rq\rq\nobreak{} or not, \ie we want a syntax like: \begin{verbatim} \begin{Description}[][