| 1 |
% % |
| 2 |
% LAYOUT_E.TEX - Short description of REFMAN.CLS |
| 3 |
% 99-03-20 |
| 4 |
% |
| 5 |
% Updated for REFMAN.CLS (LaTeX2e) |
| 6 |
% |
| 7 |
\documentclass[twoside,a4paper]{refart} |
| 8 |
\usepackage{makeidx} |
| 9 |
\usepackage{ifthen} |
| 10 |
% ifthen wird vom Bild von N.Beebe gebraucht! |
| 11 |
|
| 12 |
\def\bs{\char'134 } % backslash in \tt font. |
| 13 |
\newcommand{\ie}{i.\,e.,} |
| 14 |
\newcommand{\eg}{e.\,g..} |
| 15 |
\DeclareRobustCommand\cs[1]{\texttt{\char`\\#1}} |
| 16 |
|
| 17 |
\title{Changing the layout with \LaTeX} |
| 18 |
\author{EDV-Zentrum der TU Wien, Abt.~Digitalrechenanlage \\ |
| 19 |
Hubert Partl \\ |
| 20 |
1988-10-04 \\ |
| 21 |
English translation by\\ |
| 22 |
Axel Kielhorn\thanks{[email protected]}\\ |
| 23 |
1999-03-20 \\ |
| 24 |
H27.0 --- Version 1} |
| 25 |
|
| 26 |
\date{} |
| 27 |
\emergencystretch1em % |
| 28 |
|
| 29 |
\pagestyle{myfootings} |
| 30 |
\markboth{Changing the layout with \textrm{\LaTeX}}% |
| 31 |
{Changing the layout with \textrm{\LaTeX}} |
| 32 |
|
| 33 |
\makeindex |
| 34 |
|
| 35 |
\setcounter{tocdepth}{2} |
| 36 |
|
| 37 |
\begin{document} |
| 38 |
|
| 39 |
\maketitle |
| 40 |
|
| 41 |
\begin{abstract} |
| 42 |
This document describes the capabilities of the |
| 43 |
\texttt{refart} and \texttt{refrep} classes for \LaTeXe. |
| 44 |
These classes do not work with \LaTeX\ 2.09. They contain some |
| 45 |
improvements over the original \texttt{refman} style which may result |
| 46 |
in different output and minor incompatibilities, but make refman |
| 47 |
work with paper sizes other than ISO A4, which I consider an |
| 48 |
improvement. |
| 49 |
\end{abstract} |
| 50 |
|
| 51 |
|
| 52 |
This manual is an addition to chapter~5 (``Designing It Yourself'') of |
| 53 |
the \LaTeX-manual by Leslie Lamport. It was originally written in |
| 54 |
1988 by Hubert Partl and updated by me during the development of |
| 55 |
\texttt{refman}~2.0. The translation into English was done in summer |
| 56 |
1998, almost 10 years after the initial release in German. |
| 57 |
|
| 58 |
\tableofcontents |
| 59 |
|
| 60 |
\newpage |
| 61 |
|
| 62 |
|
| 63 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 64 |
|
| 65 |
\section{Introduction} |
| 66 |
|
| 67 |
\subsection{Author, Layout Designer and Compositor} |
| 68 |
|
| 69 |
Every piece of writing -- from a short handwritten note to a printed |
| 70 |
book -- consists of two components: \textbf{contents} and |
| 71 |
\textbf{design.} In most cases the design is only a means to allow |
| 72 |
the reader to understand the contents more easily. |
| 73 |
|
| 74 |
\index{author}\marginlabel{Author:} |
| 75 |
The \textbf{contents} will be written by the author of the document. |
| 76 |
She usually is supported by the publisher, who issues guidelines |
| 77 |
about how the document should be written and conducts proofreading. |
| 78 |
|
| 79 |
When using \LaTeX\ the contents appears in the main part of the |
| 80 |
document -- between \verb|\begin{document}| and \verb|\end{document}| |
| 81 |
-- with some additional \LaTeX-commands that describe the meaning of |
| 82 |
the different parts. |
| 83 |
|
| 84 |
\index{designer}\marginlabel{Designer:} |
| 85 |
The \textbf{design} of a printed document is usually defined by the |
| 86 |
publisher who employs designers for this purpose. |
| 87 |
|
| 88 |
The layout is defined in so-called class files. When writing a |
| 89 |
document you have to specify the class you want to use with the |
| 90 |
\verb+\documentclass+ command. |
| 91 |
|
| 92 |
The document classes distributed with \LaTeX\ have been designed by |
| 93 |
American layout designers according to the conventions used in the |
| 94 |
USA. The ``Koma-Script'' classes have been adapted to European taste |
| 95 |
and contain many small improvements. |
| 96 |
|
| 97 |
\index{compositor}\marginlabel{Compositor:} |
| 98 |
The compositor takes the contents from the author and formats it |
| 99 |
according to the layout the designer specified. |
| 100 |
|
| 101 |
When using \LaTeX, this job is done by the \TeX\ program and the |
| 102 |
printing is done by a device driver. |
| 103 |
|
| 104 |
\subsection{Changing the Layout} |
| 105 |
|
| 106 |
If you want to use a layout different from the ones distributed with |
| 107 |
\LaTeX, you have to take the following steps: |
| 108 |
|
| 109 |
\begin{enumerate} |
| 110 |
|
| 111 |
\item |
| 112 |
The layout has to be defined. |
| 113 |
This is usually a job for a professional designer. |
| 114 |
|
| 115 |
\seealso{Chapter \ref{design}} |
| 116 |
You can find detailed information about how change the design in |
| 117 |
chapter~\ref{design}. |
| 118 |
|
| 119 |
\item |
| 120 |
The layout has to be programmed in \LaTeX. This can either result in |
| 121 |
a ``package'' that changes the behaviour of a standard class, or |
| 122 |
in the definition of a new ``class''. \texttt{Refman} used to be a |
| 123 |
package that changed the definition of the \texttt{article} |
| 124 |
class but is now a class of its own. When writing a new class, you |
| 125 |
will have more work, but as a result more freedom to change things. |
| 126 |
|
| 127 |
\seealso{Chapter \ref{layout}} |
| 128 |
Chapter~\ref{layout} contains more information about the new layout. |
| 129 |
|
| 130 |
\end{enumerate} |
| 131 |
|
| 132 |
\section{The Art of Layout-Design} |
| 133 |
\label{design} |
| 134 |
\label{Layout-Design} |
| 135 |
\index{layout design} |
| 136 |
|
| 137 |
\subsection{Common Rules} |
| 138 |
\index{rules} |
| 139 |
|
| 140 |
There are almost no common rules because every kind of document has |
| 141 |
different requirements and needs a specific layout. This layout |
| 142 |
should consider \emph{who} will read the document, and \emph{how}. |
| 143 |
|
| 144 |
An important criteria is if the reader will read the document from |
| 145 |
start to end like a detective novel (linear reading) or if he wants to |
| 146 |
find certain information as in a telephone directory or a |
| 147 |
reference manual. \index{manual}\index{telephone directory} |
| 148 |
|
| 149 |
In addition to that, the layout has to consider certain conventions, |
| 150 |
like the habits of the reader or ``Corporate Design'' \index{corporate |
| 151 |
desing} rules that distinguish publications from different publishers. |
| 152 |
\footnote{Compare the layout of different daily papers or magazines |
| 153 |
like ``page'' or ``invers''.} |
| 154 |
|
| 155 |
\attention |
| 156 |
The main purpose of a layout is to make sure the reader finds the |
| 157 |
information he wants and is able to read and understand it easily. |
| 158 |
The structure, readability, and consistency of a document is more |
| 159 |
important than it's ``beauty''.\footnote{This is not always true for |
| 160 |
adverts that usually contain no information at all and, picture |
| 161 |
magazines where the beauty of the picture \emph{is} the contents.} |
| 162 |
|
| 163 |
The following ``rules of thumb''\index{rules of thumb} will be valid |
| 164 |
for most applications: |
| 165 |
|
| 166 |
\begin{description} |
| 167 |
|
| 168 |
\item[Line spacing]\index{line spacing} |
| 169 |
The spacing between two lines should be larger than the spacing |
| 170 |
between two words to guide the eyes of the reader. |
| 171 |
|
| 172 |
\item[Line length]\index{line length} |
| 173 |
The length of a line -- or when using multicolumn layout of a |
| 174 |
column -- should be about 60 characters. When lines get longer they |
| 175 |
are more difficult to read and it is easier to go to the wrong line |
| 176 |
after finishing the current one. Increasing the linespacing may help a |
| 177 |
little. |
| 178 |
When lines get to short it is difficult to set them justified, and you |
| 179 |
will get lots of hyphenated words. |
| 180 |
|
| 181 |
\item[Page layout]\index{page layout} |
| 182 |
Normal text pages should look the same throughout the document. |
| 183 |
Figures, tables and special pages like the index need not appear in |
| 184 |
the same layout but should take as much space as needed. |
| 185 |
|
| 186 |
\item[Margin notes]\index{margin notes} |
| 187 |
Margin notes are often more suitable than footnotes because they |
| 188 |
appear right next to the text they refer to. Special margin notes are |
| 189 |
the ``attention sign'' or the ``dangerous bend'' that guide the user |
| 190 |
to important parts of the text. |
| 191 |
|
| 192 |
\item[Headings and Footings]\index{headings}\index{footings} |
| 193 |
Headings and footings should make it easier for the reader to orient |
| 194 |
himself in the document. If you expect readers to copy single pages |
| 195 |
from the document they should contain information about the paper as |
| 196 |
a whole, just in case you need more information or want to cite the |
| 197 |
whole paper. |
| 198 |
|
| 199 |
If you expect the document to change often (like software manuals), |
| 200 |
each page should contain a version information or at least a date. |
| 201 |
|
| 202 |
\end{description} |
| 203 |
|
| 204 |
\subsection{Special note for technical descriptions} |
| 205 |
|
| 206 |
Let us compare three different layouts and check if they are usable for |
| 207 |
technical descriptions, user's guides and reference manuals. |
| 208 |
\footnote{This hint came from Paul Stiff, who teaches layout design at |
| 209 |
the University of Reading.} |
| 210 |
|
| 211 |
\begin{description} |
| 212 |
|
| 213 |
\item[Plain \TeX] |
| 214 |
The standard format use by plain \TeX\ has the great disadvantage |
| 215 |
that the lines are much to long, which reduces the readability. |
| 216 |
|
| 217 |
\item[Standard-\LaTeX] |
| 218 |
The format used by \LaTeX{}s standard classes isn't ideal. The |
| 219 |
line length is correct, but that leaves us with a wide unused margin. |
| 220 |
The font used for section headings is too large. The Koma-Script |
| 221 |
classes improve this and offer many ways to configure the fonts. |
| 222 |
This is a good design for a paper one usually reads from start to |
| 223 |
end. |
| 224 |
|
| 225 |
\item[Reference Manual Style] |
| 226 |
A new design that appeared some years ago and is used in recent |
| 227 |
reference manuals, is much more suited for our purpose. |
| 228 |
\footnote{The ``PostScript Reference Manual'' is one document that |
| 229 |
uses such a design.} |
| 230 |
\begin{itemize} |
| 231 |
\item |
| 232 |
The text is printed in rather short lines in the right part of the |
| 233 |
page. This part is used for continuous reading. |
| 234 |
\item |
| 235 |
The wide left margin is used for headings and margin notes. Since |
| 236 |
you now have a wide margin it is easier to use long margin notes to |
| 237 |
supply additional information and to lead the reader to important |
| 238 |
parts of the documents. Please note that the margin is always on the |
| 239 |
left side thus two-sided printing does not look symmetrical. This is |
| 240 |
done on purpose, because the reader will always start reading at the |
| 241 |
left side, and with this layout section headers really ``stand out''. |
| 242 |
In a symmetrical layout, half the headers would be buried in the text. |
| 243 |
\item |
| 244 |
Figures and tables are either inside the text column, inside the |
| 245 |
margin or, if necessary, fill the whole page. |
| 246 |
\end{itemize} |
| 247 |
|
| 248 |
\seealso{Section \ref{refmanex}} |
| 249 |
Section~\ref{refmanex} describes how to implement such a layout in |
| 250 |
\LaTeX. |
| 251 |
|
| 252 |
\end{description} |
| 253 |
|
| 254 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 255 |
|
| 256 |
|
| 257 |
\section{How to change a \LaTeX\ layout?} |
| 258 |
\label{layout} |
| 259 |
|
| 260 |
\subsection{Advantages and Disadvantages of the text processing system \LaTeX} |
| 261 |
|
| 262 |
\marginlabel{Advantages:} The big advantage of \LaTeX\ is, that it |
| 263 |
implements a ``generic'' or ``logical'' design.\index{design, |
| 264 |
logical}\index{design, generic} This means that the author has to |
| 265 |
specify the \emph{meaning} of special parts of the text like: |
| 266 |
headings, citations, lists, literature references, and so on. These |
| 267 |
logical definitions will be processed by the system and printed in |
| 268 |
the ``correct'' way. The meaning of \emph{correct} is defined in the |
| 269 |
document class and additional packages. |
| 270 |
|
| 271 |
The opposite of this is the ``visual'' design\index{design, visual} |
| 272 |
that most text processors use. Here the author has to know the correct |
| 273 |
way to set certain parts of the text and take care of the correct |
| 274 |
printing. |
| 275 |
|
| 276 |
The logical design makes it easier for the author to write |
| 277 |
consistent documents (\ie\ same font and fontsize for section headings |
| 278 |
of the same level, same layout for lists and enumerations, \dots). |
| 279 |
|
| 280 |
\marginlabel{Disadvantages:} |
| 281 |
The main disadvantage of \LaTeX\ is that the author has only limited |
| 282 |
means to change the layout and that she has only four classes to |
| 283 |
choose from. This has changed a great deal with the appearance of the |
| 284 |
Script classes for \LaTeX\ 2.09 in 1992, which in turn have been replaced by |
| 285 |
the even more improved Koma-Script classes for \LaTeXe. |
| 286 |
|
| 287 |
Another disadvantage is that \LaTeX\ seems to be tied to the |
| 288 |
``Computer modern'' font family. This is simply not true, at least |
| 289 |
not when you have a PostScript printer. Setting up different fonts |
| 290 |
isn't an easy task, but once they are installed they are as easy |
| 291 |
to use as the standard fonts. |
| 292 |
|
| 293 |
But \LaTeX\ is much more powerful and flexible: you can define an |
| 294 |
arbitrary design by changing the definitions in the class files or |
| 295 |
overwrite them by packages. This is easier than you may think and |
| 296 |
happens more often than you think. Many universities and publishers |
| 297 |
have their own \LaTeX\ class but do not distribute it to the |
| 298 |
world.\footnote{You can find a generic \texttt{elsevier.cls} on CTAN |
| 299 |
which you can use to prepare article before submission. This will be |
| 300 |
replaced by the magazine-specific class at the publisher.} |
| 301 |
|
| 302 |
|
| 303 |
\subsection{Input files and class files} |
| 304 |
|
| 305 |
According to the principle of separation of content and design, |
| 306 |
there are two kind of files: |
| 307 |
|
| 308 |
\begin{itemize} |
| 309 |
\item |
| 310 |
The content and the logical structure of a document are defined in |
| 311 |
the \LaTeX\ input file. |
| 312 |
\item |
| 313 |
The design (layout) is defined in the class files and packages. |
| 314 |
\end{itemize} |
| 315 |
Which class and packages files a document will use is defined at the |
| 316 |
beginning of the input file. The \verb|\documentclass| command |
| 317 |
selects the class and the \verb+\usepackage+ command specifies |
| 318 |
additional packages. |
| 319 |
|
| 320 |
To generate a paper you need at least two files, the input file and a |
| 321 |
class file. |
| 322 |
|
| 323 |
These two files represent the work of the author and designer as |
| 324 |
explained in the introduction. Even if the author and the designer are |
| 325 |
the same person, this has some advantages: |
| 326 |
|
| 327 |
\begin{itemize} |
| 328 |
\item |
| 329 |
Similar documents (that appear in a series) have the same layout |
| 330 |
because the layout is defined in a file of its own and not part of |
| 331 |
the document. |
| 332 |
\item |
| 333 |
You can print the same contents without much work in different |
| 334 |
layouts, \eg\ as an article for a magazine and as a chapter for a |
| 335 |
dissertation. |
| 336 |
\end{itemize} |
| 337 |
|
| 338 |
\subsection{Class files and Packages} |
| 339 |
|
| 340 |
\LaTeX\ supports a hierarchy of layout definitions. |
| 341 |
\begin{itemize} |
| 342 |
\item |
| 343 |
The first file processed is the class file that is specified inside |
| 344 |
the curly braces of the \verb|\documentclass| command. This |
| 345 |
defines the kind of document you want to write. |
| 346 |
\item |
| 347 |
The optional argument of the \verb|\documentclass| command inside |
| 348 |
the square brackets defines class options which select variants of |
| 349 |
the basic layout,such as different font sizes. |
| 350 |
\item |
| 351 |
The last step is reading the packages specified by the |
| 352 |
\verb|\usepackage| command. This command again takes options to |
| 353 |
select the layout. |
| 354 |
\item |
| 355 |
You can change layout parameters in the input file, but this is |
| 356 |
discouraged because it violates the principle of separation of |
| 357 |
content and design. |
| 358 |
|
| 359 |
\end{itemize} |
| 360 |
|
| 361 |
There are some important differences between class and package files |
| 362 |
and ``normal'' input files: |
| 363 |
\begin{itemize} |
| 364 |
\item |
| 365 |
Class and package files should only contain definitions. They must |
| 366 |
not output text. |
| 367 |
\item |
| 368 |
The ``at''-sign \texttt{@} is treated as a letter and therefore may |
| 369 |
appear in command names. Most internal commands of \LaTeX\ contain |
| 370 |
an \texttt{@} to prevent the author from using them accidentally. |
| 371 |
\item |
| 372 |
The extension of the file is \texttt{.cls}, \texttt{.clo} or |
| 373 |
\texttt{.sty} instead of \texttt{.tex}. |
| 374 |
\end{itemize} |
| 375 |
|
| 376 |
\subsection{Changing the layout, step by step} |
| 377 |
\index{changing the layout, step by step} |
| 378 |
|
| 379 |
It is usually easier to change existing class files instead of |
| 380 |
writing a new one from scratch. In many cases it is even sufficient |
| 381 |
so replace some definitions and put them into a package instead of |
| 382 |
creating a new class. |
| 383 |
|
| 384 |
Please note that you are \emph{not} allowed to change the standard |
| 385 |
classes distributed with \LaTeX. You \emph{have} to change the name |
| 386 |
when you want to make changes. That is another reason to put small |
| 387 |
changes in packages. |
| 388 |
|
| 389 |
\subsubsection{Defining the differences between the desired and |
| 390 |
the available layout} |
| 391 |
|
| 392 |
The first step is to define the difference between the layout you have |
| 393 |
and the layout you want. |
| 394 |
|
| 395 |
\subsubsection{Finding the original definition} |
| 396 |
|
| 397 |
The next step is to find out where the original layout is defined. It |
| 398 |
is best to search the files in the following order:\footnote{This hint |
| 399 |
came from Sue Brooks, who held a workshop for ``\LaTeX-Hacker'' at the |
| 400 |
1988 \TeX-conference in Exeter.} |
| 401 |
\begin{enumerate} |
| 402 |
\item the \LaTeX\ manual by Leslie Lamport, |
| 403 |
\item the \LaTeX\ documentations files \texttt{*.dtx} for the classes |
| 404 |
or packages |
| 405 |
\item the \LaTeX\ documentations files \texttt{*.dtx} for the kernel, |
| 406 |
\item the \TeX book by Donald E.~Knuth. |
| 407 |
\end{enumerate} |
| 408 |
|
| 409 |
The files are usually documented quite well so you should be able to |
| 410 |
change things even if you don't understand everything. |
| 411 |
|
| 412 |
|
| 413 |
\subsubsection{Writing a new package file} |
| 414 |
|
| 415 |
The third step is to create a new package. You choose an appropriate |
| 416 |
name for the package (like \texttt{mysty}) and create a filename by |
| 417 |
adding the extension \texttt{.sty}. |
| 418 |
|
| 419 |
This file will only contain the definitions you want to change or the |
| 420 |
new commands you want to define. |
| 421 |
|
| 422 |
If you want to change definitions or certain parameters, the best way |
| 423 |
is to copy them from the original file and modify them according to |
| 424 |
your liking. |
| 425 |
|
| 426 |
Defining new commands is easier when you find similar commands in the |
| 427 |
original files which you can change. |
| 428 |
|
| 429 |
It is always a good idea to include the reason you wrote the package, |
| 430 |
the changes it makes and the new commands it defines in the file. You |
| 431 |
should include the date of the last change and the \LaTeX\ version it |
| 432 |
works with, just in case some internal \LaTeX\ commands you use will change. |
| 433 |
|
| 434 |
When writing larger packages, it is an even better idea to use the |
| 435 |
\texttt{docstrip} program which is used to document the \LaTeXe\ files. Thus |
| 436 |
you have your code and documentation in one file and it's easier to |
| 437 |
keep them from going out of sync. |
| 438 |
|
| 439 |
\subsubsection{Using the new package} |
| 440 |
|
| 441 |
To use the new package, you call it with the \verb|\usepackage| command. |
| 442 |
This command executes the code of your package and changes the layout |
| 443 |
as desired. |
| 444 |
|
| 445 |
Example: |
| 446 |
|
| 447 |
\begin{verbatim} |
| 448 |
\documentclass[11pt,twoside,a4paper]{article} |
| 449 |
\usepackage{mysty} %<- This calls the package "mysty" |
| 450 |
\end{verbatim} |
| 451 |
|
| 452 |
You shouldn't need to change anything else in your input file, unless |
| 453 |
you defined new commands or environments that are not available in |
| 454 |
standard \LaTeX. |
| 455 |
|
| 456 |
\attention |
| 457 |
When you copy your input file to a different computer you have to |
| 458 |
include your new packages as well. Otherwise the document can't be |
| 459 |
processed. |
| 460 |
|
| 461 |
%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%%% %%%%%%%%% |
| 462 |
|
| 463 |
\subsection{A simple example (Equation numbers)} |
| 464 |
|
| 465 |
Let's assume that you want to write an article where the equations are |
| 466 |
numbered separately in every section. In the \LaTeX\ manual you find a |
| 467 |
notice that the report class does something similar for every chapter. |
| 468 |
|
| 469 |
Looking into the file \texttt{report.cls} you will find the following |
| 470 |
commands that deal with equation numbers:\nopagebreak |
| 471 |
\begin{verbatim} |
| 472 |
\@addtoreset{equation}{chapter} |
| 473 |
\def\theequation{\thechapter .\arabic{equation}} |
| 474 |
% or in LaTeX2e since 1995/06/01: |
| 475 |
\renewcommand\theequation{ |
| 476 |
\thechapter.\@arabic\c@equation |
| 477 |
} |
| 478 |
\end{verbatim} |
| 479 |
|
| 480 |
You don't necessarily need to understand these two commands in detail. |
| 481 |
|
| 482 |
Now you create an new file with the name |
| 483 |
\texttt{eqpersec.sty}\footnote{Depending on the computer you are using |
| 484 |
the name may be different like \texttt{EQPERSEC\_STY} on a CYBER |
| 485 |
running NOS/VE. But note that you must not use spaces in the |
| 486 |
filename.} and copy the commands above into that file. After that |
| 487 |
you replace every occurrence of \texttt{chapter} with \texttt{section} |
| 488 |
and add some comments.\nopagebreak |
| 489 |
\begin{verbatim} |
| 490 |
% This is equation_per_section.sty |
| 491 |
% Short name: eqpersec.sty |
| 492 |
% Original file by Hubert Partl 1988 |
| 493 |
% Modified by Axel Kielhorn 1996/01/01 |
| 494 |
% to support LaTeX 1995/06/01 and later |
| 495 |
% |
| 496 |
% reset the equation counter at the start |
| 497 |
% of a new section |
| 498 |
% |
| 499 |
\@addtoreset{equation}{section} |
| 500 |
% Equationnumber = sectionnummer.equationnummer |
| 501 |
% Use only one of the below |
| 502 |
% depending on you LaTeX version |
| 503 |
% |
| 504 |
%\def\theequation{\thesection .\arabic{equation}} |
| 505 |
% or in more recent versions of LaTeX |
| 506 |
\renewcommand\theequation{ |
| 507 |
\thesection.\@arabic\c@equation |
| 508 |
} |
| 509 |
\end{verbatim} |
| 510 |
|
| 511 |
|
| 512 |
Whenever you use a \verb|\usepacakge{eqpersec}| command as in |
| 513 |
\nopagebreak |
| 514 |
\begin{verbatim} |
| 515 |
\documentclass[11pt]{article} |
| 516 |
\usepackage{eqpersec} |
| 517 |
\end{verbatim} |
| 518 |
you will get equations numbered according to your conventions. |
| 519 |
|
| 520 |
|
| 521 |
%%%%%%%%%% %%%%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%%%%%% %%%%%%%% %%%%%%%%%%%% |
| 522 |
|
| 523 |
\subsection{A more complex example (Reference Manual)} |
| 524 |
\label{refmanex} |
| 525 |
|
| 526 |
We want to create a layout similar to the one used in the \textit{PostScript |
| 527 |
Reference Manual}, with a wide left margin for headings and margin |
| 528 |
notes and a small margin at the right and bottom. |
| 529 |
|
| 530 |
\subsubsection{Page layout} |
| 531 |
|
| 532 |
To define the new layout we use the commands described in the \LaTeX\ |
| 533 |
manual. For full details see the file \texttt{refman.dtx}. |
| 534 |
|
| 535 |
%\pagebreak[2] |
| 536 |
|
| 537 |
\marginlabel{Horizontal:} |
| 538 |
First we define two new names for length that we will use often: |
| 539 |
|
| 540 |
\cs{fullwidth} is the width of the whole page minus a margin of 1~inch |
| 541 |
on every side. |
| 542 |
% |
| 543 |
\begin{displaymath} |
| 544 |
\texttt{fullwidth} = \texttt{paperwidth} - 2\ \textrm{inch} |
| 545 |
\end{displaymath} |
| 546 |
% |
| 547 |
From this the width of the text is calculated. |
| 548 |
% |
| 549 |
\begin{displaymath} |
| 550 |
\texttt{textwidth} = \texttt{fullwidth} \times \texttt{textfraction} |
| 551 |
\end{displaymath} |
| 552 |
% |
| 553 |
\cs{leftmarginwidth} is the width of the left margin that will be |
| 554 |
used for headings and margin notes. |
| 555 |
\begin{displaymath} |
| 556 |
\texttt{leftmarginwidth} = \texttt{fullwidth} - \texttt{textwidth} |
| 557 |
\end{displaymath} |
| 558 |
% |
| 559 |
This is a little more difficult in reality because the lengths have to |
| 560 |
be rounded to full points and a possible two column layout -- as used |
| 561 |
in the index -- must be taken into consideration. |
| 562 |
|
| 563 |
\marginlabel{Vertical:} |
| 564 |
The vertical layout is a little more difficult because you have to |
| 565 |
deal with the page header and footer. |
| 566 |
% |
| 567 |
\begin{displaymath} |
| 568 |
\texttt{textheight} = \texttt{paperheight} - 2.5\ \textrm{inch} |
| 569 |
\end{displaymath} |
| 570 |
% |
| 571 |
The result of this calculation is rounded to full lines. Depending on |
| 572 |
the page style -- headings or footings -- it is shifted up or down by one |
| 573 |
line. |
| 574 |
|
| 575 |
\vspace{0pt plus 1cm} |
| 576 |
|
| 577 |
\subsubsection{Section headings} |
| 578 |
|
| 579 |
The headings have to be modified to make them extend into the left |
| 580 |
margin. |
| 581 |
|
| 582 |
In file \texttt{classes.dtx} we find the \verb|\@startsection| command |
| 583 |
that defines the layout of the headings. Only parameters 4 to 6 are |
| 584 |
relevant for us: parameter 4 is the space above and parameter 5 the |
| 585 |
space below the section. The 6th parameter does the actual formatting. |
| 586 |
|
| 587 |
This is the original definition:\nopagebreak |
| 588 |
\begin{verbatim} |
| 589 |
\newcommand\section{\@startsection |
| 590 |
{section}{1}{\z@}% |
| 591 |
{-3.5ex plus -1ex minus -.2ex}% |
| 592 |
{2.3ex plus .2ex}% |
| 593 |
{\normalfont\Large\bfseries}} |
| 594 |
\end{verbatim} |
| 595 |
|
| 596 |
The commands for sub- and subsubsections are similar. Note that the |
| 597 |
measures are all in \texttt{ex}, thus depending on the font size used. |
| 598 |
|
| 599 |
We define a new command \cs{secshape} to format the headings. This |
| 600 |
command uses the whole width of the page for the heading. To discourage |
| 601 |
hyphenation of the heading we give it a high penalty. This still |
| 602 |
allows hyphenation when absolutely necessary. |
| 603 |
|
| 604 |
\begin{verbatim} |
| 605 |
\newcommand\secshape{% |
| 606 |
\leftskip=-\leftmarginwidth% |
| 607 |
\rightskip=\@flushglue% |
| 608 |
\hyphenpenalty=2000} |
| 609 |
\end{verbatim} |
| 610 |
|
| 611 |
This command is inserted into the 6th parameter of \verb|\@startsection|. |
| 612 |
|
| 613 |
Since the headings now extend into the left margin, we can use a |
| 614 |
smaller font and reduce the space between the text and the heading. The |
| 615 |
new definition looks like the following:\nopagebreak |
| 616 |
\begin{verbatim} |
| 617 |
\newcommand\section{\@startsection |
| 618 |
{section}{1}{\z@}% |
| 619 |
{-2ex plus -1ex minus -.2ex}% |
| 620 |
{0.5ex plus .2ex}% |
| 621 |
{\secshape\normalfont\large\bfseries}} |
| 622 |
\end{verbatim} |
| 623 |
|
| 624 |
\vspace{0pt plus 1cm} |
| 625 |
|
| 626 |
\subsubsection{Setting the margin notes} |
| 627 |
|
| 628 |
The margin notes should always appear on the left side of the text. |
| 629 |
The normal layout puts them into the outer margin in twoside layout. |
| 630 |
|
| 631 |
The file \texttt{latex.dtx} contains the definition of the |
| 632 |
\verb|\@addmarginpar| command which is responsible for the margin |
| 633 |
notes. We don't have to understand the whole definition; the important |
| 634 |
part is the internal variable \verb|\@tempcnta| that is either |
| 635 |
\verb|\@ne| (1) when the note should appear on the right side of the |
| 636 |
text or \verb|\m@ne| ($-1$) when it should appear on the left side. |
| 637 |
|
| 638 |
This is done by the following lines: |
| 639 |
\begin{verbatim} |
| 640 |
\@tempcnta\@ne |
| 641 |
\if@twocolumn |
| 642 |
\if@firstcolumn \@tempcnta\m@ne \fi |
| 643 |
\else |
| 644 |
\if@mparswitch |
| 645 |
\ifodd\c@page \else\@tempcnta\m@ne \fi |
| 646 |
\fi |
| 647 |
\if@reversemargin \@tempcnta -\@tempcnta \fi |
| 648 |
\fi |
| 649 |
\end{verbatim} |
| 650 |
|
| 651 |
which we simply replace by: |
| 652 |
\begin{verbatim} |
| 653 |
\@tempcnta\m@ne |
| 654 |
\end{verbatim} |
| 655 |
|
| 656 |
The remaining lines that handle the setting of the margin note |
| 657 |
depending on the parameter \verb|\@tempcnta| are left unchanged. |
| 658 |
|
| 659 |
\subsubsection{Extensions} |
| 660 |
|
| 661 |
The definitions described above are sufficient for simple applications |
| 662 |
but in practical use one may want some additional commands. |
| 663 |
\seealso{Appendix \ref{refman}} You will find the description for the whole new |
| 664 |
class in the appendix~\ref{refman}. |
| 665 |
|
| 666 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 667 |
|
| 668 |
\input lay_e2 |
| 669 |
|
| 670 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 671 |
|
| 672 |
\printindex |
| 673 |
|
| 674 |
\end{document} |