Outils pour utilisateurs

Outils du site


issue206:latex

Ceci est une ancienne révision du document !


This time we are going to examine the first instruction in a Latex document file. Every Latex document starts with: \documentclass[]{}. What the writer puts inside the curly braces sets much document formatting in place before a single word of text is written. In most of the examples seen in Full Circle Monthly the document class has been article. That is the quickest and easiest document class to show in these pages. For the purposes of the examples in previous issues the document class chosen has had no consequences on the results of the example. This time we are going to look at what the article class entails, what other options are available and what parameters can be put into the square brackets.

There are four standard document classes: article, report, letter and book. The text of a document can be split into parts which generate a hierarchical structure. The parts of that structure are determined by the document class being used. There are five standard levels: part, chapter, section, subsection, subsubsection. Class book and class report can use all five, class article cannot use part and chapter. Letter class cannot use any of the five hierarchical levels. As you know if you have been reading this series Latex packages are often included in the preamble of documents. These additional packages may define other levels of sectioning.

Note: There is a fifth document class: slides. It is used to set the default configuration for slide presentations. It is rarely used. I will not discuss its features in this article.

There are two more divisions allowed in standard Latex: paragraph and subparagraph. They are not used to force the start of new paragraphs. They are used to indicate divisions lower in the hierarchy than subsubparagraph without using a ridiculous number of “sub-” prefices.

Note: users are also able to define new Latex macros in document preambles. These custom macros may be used to define the features of new document divisions.

When complete the documentclass command will look like the following:

\documentclass[font size,paper size, other possible options]{class}

As you would expect all of the options have their defaults. Quite often when making Latex documents I use only the class and set the other options through whatever packages I have included.

Because of the technology available when Tex was written (early 1970s) there are only three font sizes available to the documentclass command: 10pt, 11pt, 12pt with 10pt being the default. This is not a problem. Review my article in FCM 189 for some instructions about using fonts in Latex.

There are six paper sizes which can be specified. Latex users in North America get a break here. The default paper size is letterpaper which is 8.5 x 11 inches so it does not need to be specified. The five other paper sizes available to documentclass are: a4paper, a5paper, b5paper, executivepaper and legalpaper. In North America we are familiar with legal paper, 8.5 x 14 inches. A4, A5, B5 are generally well-known in the rest of the world. Executive is smaller than letter, only 7.25in x 10.5in. I believe it is a standard size for writing letters.

If you need to use a paper size different from these six then you need to define the physical page size. One way to do that is to define the page width and height using \pdfpaagewidth and \pdfpageheight. A more flexible way is to include the geometry package which gives many options for the physical size and the print area.

Other possible options for the documentclass command: landscape: selects landscape setup (long side of page will be horizontal), default is portrait (short side of page will be horizontal). draft / final: Mark (draft) or do not mark (final – default) overfull boxes with a black box in the margin fleqn: force formulas to be flush-left, default is centered leqno: insert equation numbers to left of equations, default is to the right openbib: use the “open” bibliography format titlepage (default for reports) / notitlepage (default for other printed documents): specifies if there is to be a separate page for title and for abstract onecolumn (default) / two column: typeset in one or two columns (this one should be obvious as should be the next one) openright / openany: for the book class, openright is the default. It means every chapter starts on a right hand (odd-numbered) page. All others default to openany. oneside / twoside: one or two-sided layout, twoside is default for the book class, all others are oneside by default

Special considerations

Oneside means the text will be placed in a “window” which is centred between the margins.

Twoside means the size of the text window must be calculated since the margins for the left hand and right hand pages are mirror images. In twoside there are no margins labelled left and right. Rather they are labelled inner and outer in most desktop publishing and word processing software. In Latex / Tex they are also called oddside and evenside. Inside margins are usually wider than outside margins in order to have enough paper for binding the book. Of course, if your book is only to be printed electronically (PDF) then inside and outside margins can be equal.

As I am sure you realize, demonstrating many of these possibilities is not effective in FCM. Changing paper size or orientation , changing document class, and others cannot be observed in this format. There are a few which can be changed. Follow the code (previous page) and the images (below) to see a few examples.

issue206/latex.1719675278.txt.gz · Dernière modification : 2024/06/29 17:34 de auntiee