%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Contents: Specialties of the LaTeX system % $Id: spec.tex,v 1.2 1996/01/25 14:01:06 oetiker Exp oetiker $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \chapter{Specialities} \begin{intro} Don't read this chapter! --- Or, at least, if you feel confident enough, you can now start writing your documents in \LaTeX{}. The purpose of this chapter is to add some `spice' to your \LaTeX{} knowledge. A much more complete description of specialities and enhancements possible with \LaTeX{} can be found in the {\normalfont\manual{}} and {\normalfont \companion}. \end{intro} \section{Fonts and Sizes} \index{font}\index{font size} \LaTeX{} chooses the appropriate font and font size based on the logical structure of the document (sections, footnotes, \ldots). In some cases one might like to change fonts and sizes by hand. To do this you can use the commands listed in Tables~\ref{fonts} and~\ref{sizes}. The actual size of each font is a design issue and depends on the document class and its options. \begin{example} {\small The small and \textbf{bold} Romans ruled} {\Large all of great big \textit{Italy}.} \end{example} One important feature of \LaTeXe{} is, that the font attributes are independent. This means, that you can change issue size or even font changing commands and still keep the bold or slant attribute set earlier. While this may be evident to someone learning \LaTeX{} from scratch, it is not all that clear the someone used to \LaTeX{} 2.09. In \emph{math mode} you can use the font changing \emph{commands} to temporarily exit \emph{math mode} and enter some normal text. If you want to switch to another font for math typesetting there exists another special set of commands. Refer to Table~\ref{mathfonts}. \begin{table}[!bp] \caption{Fonts} \label{fonts} \begin{lined}{12cm} % % Alan suggested not to tell about the other form of the command % eg \verb|\sffamily| or \verb|\bfseries|. This seems a good thing to me. % \begin{tabular}{@{}rl@{\qquad}rl@{}} \ci{textrm}\verb|{...}| & \textrm{\wi{roman}}& \ci{textsf}\verb|{...}| & \textsf{\wi{sans serif}}\\ \ci{texttt}\verb|{...}| & \texttt{typewriter}\\[6pt] \ci{textmd}\verb|{...}| & \textmd{medium}& \ci{textbf}\verb|{...}| & \textbf{\wi{bold face}}\\[6pt] \ci{textup}\verb|{...}| & \textup{\wi{upright}}& \ci{textit}\verb|{...}| & \textit{\wi{italic}}\\ \ci{textsl}\verb|{...}| & \textsl{\wi{slanted}}& \ci{textsc}\verb|{...}| & \textsc{\wi{small caps}}\\[6pt] \ci{emph}\verb|{...}| & \emph{emphasised} & \ci{textnormal}\verb|{...}| & \textnormal{document} font \end{tabular} \bigskip \end{lined} \end{table} \begin{table}[!bp] \index{font size} \caption{Font sizes} \label{sizes} \begin{lined}{12cm} \begin{tabular}{@{}ll} \ci{tiny} & \tiny tiny font \\ \ci{scriptsize} & \scriptsize very small font\\ \ci{footnotesize} & \footnotesize quite small font \\ \ci{small} & \small small font \\ \ci{normalsize} & \normalsize normal font \\ \ci{large} & \large large font \end{tabular}% \qquad\begin{tabular}{ll@{}} \ci{Large} & \Large larger font \\[5pt] \ci{LARGE} & \LARGE very large font \\[5pt] \ci{huge} & \huge huge \\[5pt] \ci{Huge} & \Huge largest \end{tabular} \bigskip \end{lined} \end{table} \begin{table}[!bp] \caption{Math fonts} \label{mathfonts} \begin{lined}{12.2cm} \begin{tabular}{@{}lll@{}} \textit{Command}&\textit{Example}& \textit{Output}\\[6pt] \ci{mathcal}\verb|{...}|& \verb|$\mathcal{B}=c$|& $\mathcal{B}=c$\\ \ci{mathrm}\verb|{...}|& \verb|$\mathrm{K}_2$|& $\mathrm{K}_2$\\ \ci{mathbf}\verb|{...}|& \verb|$\sum x=\mathbf{v}$|& $\sum x=\mathbf{v}$\\ \ci{mathsf}\verb|{...}|& \verb|$\mathsf{G\times R}$|& $\mathsf{G\times R}$\\ \ci{mathtt}\verb|{...}|& \verb|$\mathtt{L}(b,c)$|& $\mathtt{L}(b,c)$\\ \ci{mathnormal}\verb|{...}|& \verb|$\mathnormal{R_{19}}\neq R_{19}$|& $\mathnormal{R_{19}}\neq R_{19}$\\ \ci{mathit}\verb|{...}|& \verb|$\mathit{ffi}\neq ffi$|& $\mathit{ffi}\neq ffi$ \end{tabular} \bigskip \end{lined} \end{table} In connection with the font size commands, \wi{curly braces} play a significant role. They are used to to build \emph{groups}. Groups limit the scope of most \LaTeX{} commands.\index{grouping} \begin{example} He likes {\LARGE large and {\small small} letters}. \end{example} The font size commands also change the line spacing, but only if the paragraph ends within the scope of the font size command. The closing curly brace \verb|}| should therefore not come too early. Note the position of the \verb|\par| command in the next two examples. \begin{example} {\Large Don't read this! It is not true. You can believe me!\par} \end{example} \begin{example} {\Large This is not true. But remember I am a liar.}\par \end{example} To conclude this journey into the land of fonts and font sizes, here is a little word of advice\footnote{Attention: This is a bit of satire. I hope you realise that!}:\nopagebreak \begin{quote} \underline{\textbf{Remember\Huge!}} \textit{The} \textsf{M\textbf{\LARGE O} \texttt{R}\textsl{E}} fonts \Huge you \tiny use \footnotesize \textbf{in} a \small \texttt{document} \large \textit{the} \normalsize more \textsc{readable} and \textsl{\textsf{beautiful} it bec\large o\Large m\LARGE e\huge s}. \end{quote} % % Add some notes about the \begin{Large} commands % \section{Spacing} \subsection{Line Spacing} \index{line spacing} If you want to use larger inter line spacing in a document, you can change its value by putting the \begin{command} \ci{linespread}\verb|{|\emph{factor}\verb|}| \end{command} \noindent command into the preamble of your document. Use \verb|\linespread{1.3}| for ``one and a half'' line spacing, and \verb|\linespread{1.6}| for ``double'' line spacing. Normally the lines are not spread, therefore the default line spread factor is~1.\index{double line spacing} \subsection{Paragraph Formating}\label{parsp} In \LaTeX{}, there are two parameters influencing paragraph layout. By placing a definition like \begin{code} \ci{setlength}\verb|{|\ci{parindent}\verb|}{0pt}| \\ \verb|\setlength{|\ci{parskip}\verb|}{1ex plus 0.5ex minus 0.2ex}| \end{code} in the preamble\footnote{Between the $\backslash$\texttt{documentclass} and the $\backslash$\texttt{begin$\mathtt{\{}$document$\mathtt{\}}$} commands} of the input file the appearance of paragraphs can be changed. These two lines increase the space between two paragraphs while setting the paragraph indent to zero. In continental Europe, paragraphs are often separated by some space and not indented. But beware, this has also its effect on the table of contents. Its lines get spaced more loosely now as well. If you want to indent a paragraph which is not indented, you can use \begin{command} \ci{indent} \end{command} \noindent at the beginning of the paragraph\footnote{To indent the first paragraph after each section head, use the \pai{indentfirst} package in the `tools' bundle}. Obviously this can only work, when \verb|\parindent| is not set to zero. To create a non-indented paragraph you can use \begin{command} \ci{noindent} \end{command} \noindent as the first command of the paragraph. This might come in handy, when you start a document with body text and not with a sectioning command. \subsection{Horizontal Space} \LaTeX{} determines the spaces between words and sentences automatically. To add horizontal space, use: \index{horizontal!space} \begin{command} \ci{hspace}\verb|{|\emph{length}\verb|}| \end{command} If such a space should be kept, even if it falls at the end or the start of a line, use \verb|\hspace*| instead of \verb|\hspace|. The \emph{length} in the simplest case just is a number plus a unit. The most important units are listed in Table~\ref{units}. \index{units}\index{dimensions} \begin{example} This\hspace{1.5cm}is a space of 1.5 cm. \end{example} \suppressfloats \begin{table}[tbp] \caption{\TeX{} Units} \label{units}\index{units} \begin{lined}{9.5cm} \begin{tabular}{@{}ll@{}} \texttt{mm} & millimetre $\approx 1/25$~inch \quad \demowidth{1mm} \\ \texttt{cm} & centimetre = 10~mm \quad \demowidth{1cm} \\ \texttt{in} & inch $\approx$ 25.4~mm \quad \demowidth{1in} \\ \texttt{pt} & point $\approx 1/72$~inch $\approx \frac{1}{3}$~mm \quad\demowidth{1pt}\\ \texttt{em} & approx width of an \texttt{m} in the current font \quad \demowidth{1em}\\ \texttt{ex} & approx height of an \texttt{x} in the current font \quad \demowidth{1ex} \end{tabular} \bigskip \end{lined} \end{table} The command \begin{command} \ci{stretch}\verb|{|\emph{n}\verb|}| \end{command} \noindent generates a special rubber space. It stretches, until all the remaining space on a line is filled up. If two \verb|\hspace{\stretch{|\emph{n}\verb|}}| commands are issued on the same line, they grow according to the stretch factor. \begin{example} x\hspace{\stretch{1}} x\hspace{\stretch{3}}x \end{example} \subsection{Vertical Space} The space between paragraphs, sections, subsections, \ldots\ is determined automatically by \LaTeX. If necessary, additional vertical space \emph{between two paragraphs} can be added with the command: \begin{command} \ci{vspace}\verb|{|\emph{length}\verb|}| \end{command} This command should normally be used between two empty lines. If the space should be preserved at the top, or at the bottom of a page, use the starred version of the command \verb|\vspace*| instead of \verb|\vspace|. \index{vertical space} The \verb|\stretch| command in connection with \verb|\pagebreak| can be used to typeset text on the last line of a page, or to centre text vertically on a page. \begin{code} \begin{verbatim} Some text \ldots \vspace{\stretch{1}} This goes onto the last line of the page.\pagebreak \end{verbatim} \end{code} Additional space between two lines of \emph{the same} paragraph or within a table is specified with the \begin{command} \ci{\bs}\verb|[|\emph{length}\verb|]| \end{command} \noindent command. \section{Page Layout} \begin{figure}[!hp] \begin{center} \makeatletter\@layout\makeatother \end{center} \vspace*{1.8cm} \caption{Page Layout Parameters} \label{fig:layout} \end{figure} \index{page layout} \LaTeXe{} allows you to specify the \wi{paper size} in the \verb|\documentclass| command. It then automatically picks the right text \wi{margins}. But some times, you may not be happy with the predefined values. Naturally, you can change them. %no idea why this is needed here ... \thispagestyle{fancyplain} Figure~\ref{fig:layout} shows all the parameters which can be changed. The figure was produced with the \pai{layout} package from the tools bundle% \footnote{\texttt{CTAN:/tex-archive/macros/latex/packages/tools}}. \LaTeX{} provides two commands to change these parameters. They are usually used in the document preamble. The first command assigns a fixed value to any of the parameters: \begin{command} \ci{setlength}\verb|{|\emph{parameter}\verb|}{|\emph{length}\verb|}| \end{command} The second command, adds a length to any of the parameters. \begin{command} \ci{addtolength}\verb|{|\emph{parameter}\verb|}{|\emph{length}\verb|}| \end{command} This second command is actually more useful than the \ci{setlength} command, because you can now work relative to the existing settings. To add one centimetre to the overall text width, I would put the following commands into the document preamble: \begin{code} \verb|\addtolength{\hoffset}{-0.5cm}|\\ \verb|\addtolength{\textwidth}{1cm}| \end{code} \section{Bibliography} With the \ei{thebibliography} environment you can produce a \wi{bibliography}. Each entry starts with \begin{command} \ci{bibitem}\verb|{|\emph{marker}\verb|}| \end{command} The \emph{marker} is then used to cite the book within the document. \begin{command} \ci{cite}\verb|{|\emph{marker}\verb|}| \end{command} The numbering of the entries is generated automatically. The parameter after the \verb|\begin{thebibliography}| command sets the maximum width of these numbers. \begin{example} Partl~\cite{pa} has proposed, that \ldots \begin{thebibliography}{99} \bibitem{pa} H.~Partl: \emph{German \TeX}, TUGboat Vol.~9, No.~1 ('88) \end{thebibliography} \end{example} \chaptermark{Specialities} % w need to fix the damage done by the %bibliography example. \thispagestyle{fancyplain} \section{Indexing} \label{sec:indexing} A very useful feature of many books is their \wi{index}. With \LaTeX{} and the support program \texttt{makeindex}\footnote{On systems not supporting filenames longer than 8~characters, the program may be called \texttt{makeidx}.} indexes can be generated quite easily. In this introduction, only the basic index generation commands will be explained. For a more in depth view please refer to \companion. \index{makeindex program} \index{makeidx package} To enable the indexing feature of \LaTeX{} the \pai{makeidx} package must be loaded in the preamble with: \begin{command} \verb|\usepackage{makeidx}| \end{command} \noindent and the special indexing commands must be enabled by putting the \begin{command} \ci{makeindex} \end{command} \noindent command into the input files preamble. The contents of the index is specified with \begin{command} \ci{index}\verb|{|\emph{key}\verb|}| \end{command} \noindent commands. Where \emph{key} is the index entry. You enter the index commands at the points in the text where you want the final index entries to point to. Table~\ref{index} explains the syntax of the \emph{key} argument with several examples. \begin{table}[!tp] \caption{Index Key Syntax Examples} \label{index} \begin{center} \begin{tabular}{@{}lll@{}} \textbf{Example} &\textbf{Index Entry} &\textbf{Comment}\\\hline \rule{0pt}{1.05em}\verb|\index{hello}| &hello, 1 &Plain entry\\ \verb|\index{hello!Peter}| &\hspace*{2ex}Peter, 3 &Subentry under `hello'\\ \verb|\index{Sam@\textsl{Sam}}| &\textsl{Sam}, 2& Formated entry\\ \verb|\index{Lin@\textbf{Lin}}| &\textbf{Lin}, 7& Same as above\\ \verb.\index{Jenny|textbf}. &Jenny, \textbf{3}& Formated page number\\ \verb.\index{Joe|textit}. &Joe, \textit{5}& Same as above \end{tabular} \end{center} \end{table} When the input file is processed with \LaTeX{}, each \verb|\index| command writes an appropriate index entry together with the current page number to a special file. The file has the same name as the \LaTeX{} input file, but a different extension (\verb|.ind|). This \texttt{.ind} file can then be processed with the \texttt{makeindex} program. \begin{command} \texttt{makeindex} \emph{filename} \end{command} The \texttt{makeindex} program generates a sorted index with the same base file name, but this time with the extension \texttt{.idx}. If now the \LaTeX{} input file is processed again, this sorted index gets included into the document at the point where \LaTeX{} finds \begin{command} \ci{printindex} \end{command} The \pai{showidx} package which comes with \LaTeXe{} prints out all index entries in the left margin of the text. This is quite useful for proofreading a document and verifying the index. % Add some infos on PROTECT ... \section{Including EPS Graphics} With the \texttt{figure} and the \texttt{table} environment \LaTeX{} provides the basic facilities to work with floating bodies such as images or graphics. There are also several possibilities to generate the actual \wi{graphics} with basic \LaTeX{} or a \LaTeX{} extension package. Unfortunately, most users find them quite difficult to understand. Therefore this will not be explained any further in this manual. For more information on that subject please refer to \companion{} and the \manual. A much easier way to get graphics into a document, is to generate them with a specialised software package\footnote{Such as XFig, CorelDraw!, Freehand, Gnuplot, \ldots} and then include the finished graphics into the document. Here again, \LaTeX{} packages offer many ways to do that. In this introduction, only the use of \wi{Encapsulated PostScript} (EPS) graphics will be discussed, because it is quite easy to do and widely used. In order to use pictures in the EPS format, you must have a \wi{PostScript} printer\footnote{Another possibility to output PostScript is the \textsc{\wi{GhostScript}} program available from \texttt{CTAN:/tex-archive/support/ghostscript}} available for output. A good set of commands for inclusion of graphics is provided in the \pai{graphicx} package by D.~P.~Carlisle. It is part of a whole family of packages called the ``graphics'' bundle\footnote{\texttt{CTAN:/tex-archive/macros/latex/packages/graphics}}. Assuming you are working on a system with a PostScript printer available for output and with the \textsf{graphicx} package installed, you can use the following step by step guide to include a picture into your document: \begin{enumerate} \item Export the picture from your graphics program in EPS format. \item Load the \textsf{graphicx} package in the preamble of the input file with \begin{command} \verb|\usepackage[|\emph{driver}\verb|]{graphicx}| \end{command} \emph{driver} is the name of your ``dvi to postscript'' converter\footnote{The most widely used program is called \texttt{dvips}.}. This information is required by the package because the actual graphics inclusion is done by the printer driver. Knowing the \emph{driver}, the \textsf{graphicx} package inserts the correct commands into the \texttt{.dvi}~file for the printer driver to include the desired EPS graphics. \item Use the command \begin{command} \ci{includegraphics}\verb|[|\emph{key}=\emph{value}, \ldots\verb|]{|\emph{file}\verb|}| \end{command} to include \emph{file} into your document. The optional parameter accepts a comma separated list of \emph{keys} and associated \emph{values}. The \emph{keys} can be used to alter the width, height and rotation of the included graphic. Table~\ref{keyvals} lists the most important keys. \end{enumerate} \begin{table}[htb] \caption{Key Names for \textsf{graphicx} Package} \label{keyvals} \begin{lined}{9cm} \begin{tabular}{@{}ll} \texttt{width}& scale graphic to the specified width\\ \texttt{height}& scale graphic to the specified height\\ \texttt{angle}& rotate graphics clockwise \end{tabular} \bigskip \end{lined} \end{table} The following example code will hopefully make things clear: \begin{code} \begin{verbatim} \begin{figure} \begin{center} \includegraphics[angle=90, width=10cm]{test.eps} \end{center} \end{figure} \end{verbatim} \end{code} This includes the graphic stored in the file \texttt{test.eps}. The graphic is \emph{first} rotated by 90 degrees and \emph{then} scaled to the final width of 10\,cm. The aspect ratio is 1.0 because no special height is specified. For more information please refer to~\cite{graphics}. \endinput %%% Local Variables: %%% mode: latex %%% TeX-master: "lshort2e" %%% End: