21.04.2015 Views

Introducing Latex - Bruce E. Shapiro

Introducing Latex - Bruce E. Shapiro

Introducing Latex - Bruce E. Shapiro

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

where the exclamation point (!) should be replaced<br />

by any character that is not include in code . For<br />

example, the following are equivalent:<br />

\verb.C123_=A_+B_.<br />

\verb^C123_=A_+B_^<br />

and each will insert the string C123_=A_+B_ into your<br />

document.<br />

5.9 Boxes Around Text<br />

The \fbox is convenient for putting boxes around<br />

text; if you typeset \fbox{like this} it will look<br />

like this .<br />

Getting boxes around verbatim text is more complicated,<br />

but you can use the following template (this<br />

is what was used in this document) to make it work.<br />

First, include the line<br />

\usepackage{fancyvrb}<br />

in the preable. The following template will create<br />

a three-inch wide box with your code left-justified<br />

inside the box. If you want the box to be wider,<br />

change the width from 3in to something else. If you<br />

don’t want the box to be in the center of your page,<br />

leave out the center environment.<br />

\begin{center}<br />

\begin{minipage}{3in}<br />

\begin{Verbatim}[frame=single]<br />

%<br />

% put you code here<br />

%<br />

\end {Verbatim}<br />

\end{minipage}<br />

\end{center}<br />

For more details refer to the <strong>Latex</strong> reference on<br />

minipage and fancyvrb.<br />

5.10 Counters and labels<br />

thepage gives the current page number.<br />

thechapter gives the current chapter number.<br />

thesection gives the current section number.<br />

To refer to a particular section, chapter, etc., you can<br />

label it. Immediately after the \section command<br />

include a label command, for example,<br />

\label{section-Quadratics}<br />

Then to refer to that section, use<br />

as in,<br />

\ref{section-Quadratics}.<br />

In section \ref{section-Quadratics}<br />

we will learn how to solve the<br />

quadratic equation (see page<br />

\pageref{page-quad}).<br />

To refer to a particular page, use the \pageref command<br />

to refer to any label on that page, as in the<br />

above example.<br />

5.11 Headers and Footers<br />

By default the page number is printed in the bottom<br />

center of the page, with no other headers and<br />

footers.a<br />

pagestyle{empty} in the preamble will turn off all<br />

headers and footers, including page numbers.<br />

To define your own headers and footers put<br />

\usepackage{fancyhdr}<br />

in the preamble, then define your own style.<br />

single sided documents, still in the preamble:<br />

For<br />

\fancypagesytel{mystyle}{<br />

\lhead{Text for the top left of the page}<br />

\chead{Text for the top center of the page}<br />

\rhead{Text for the top right of the page}<br />

\lfoot{Text for the bottom left of the page}<br />

\cfoot{Text for the bottom center of the page}<br />

\rfoot{Text for the bottom right of the page}<br />

}<br />

\renewcommand{\footrulewidth}{0.4pt}<br />

\renewcommand{\headrulewidth}{0.4pt}<br />

The footrulewidth and the headrulewidth give<br />

the thickness of lines between the text and the<br />

header and footer. By default the headrule is set<br />

<strong>Introducing</strong> L A TEX (rev. 2012.1) Page 10

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!