Skip to content

Brief Guide on LaTeX

Leothelion edited this page Jul 8, 2024 · 1 revision

Structure

Preparing a document in LaTeX involves a sequence of loading things that handle different aspects of typesetting and typography, typically from that of the largest order (layouts) to the smallest (macro for short-hands)

%    Pre-class preamble
%
%    \RequirePackage{ pkg } to load packages
%    \PassOptionsToPackage{ option }{ pkg }  to pass options to packages
%
\documentclass[ options ]{ classname }
%
% 
%    Preamble
%
%    \usepackage{ pkg }            or
%    \usepackage[ options ]{ pkg } to load packages
%
%
\begin{document}

% magic happens here

\end{document}

Document class

Document classes, or simply classes, define the layout standards you want to use for typesetting adocument. These standards are contained within class files, which typically have the .cls extension. Loading a class is demonstrated above, as below as an example of loading the article class:

\documentclass[ options ]{ article }

It is strongly recommended that in LaTeX, the first line of your TeX file should be the \documentclass command. This is because the class you choose will determine the layout of your document, and it is important to set this before you start writing your document. These classes handle not only different types of documents, but also aspects like paper size, font size and the number of columns and so on.

Default classes and options

There are literally hundreds of classes for LaTeX available on CTAN. Though, there are four default classes that come with LaTeX:

  • article for articles in scientific journals, presentations, short reports, program documentation, invitations, ...
  • book for book(let)s, reports, theses, ...
  • report for technical, legal, or academic reports; theses and dissertations
  • letter for letters

By default, all four classes have 10pt font size, single-column text, have two-sided (book and report) or one-sided printing (article and letter), and are set in final mode (as in camera-ready).

The following table shows the general options for the default LaTeX document classes:

What Options Description
font size 10pt, 11pt, 12pt Sets the font size for the document
paper size a4paper, letterpaper, legalpaper, executivepaper Sets the paper size for the document
orientation landscape Sets the orientation of the paper; portrait is default
columns twocolumn Instructs LaTeX to typeset the document in two columns instead of one
sidedness oneside, twoside Specifies whether the double/single sided output should be generated. This is a specification of recto/verso printing rather than literally printing on one or both sides of the paper
draft mode draft, final This option tells LaTeX to mark overfull boxes in the output, so you can see where text is running into the margins

These are absolutely basic in terms of what they offer, perhaps to allow the user customise the document to their liking by adding packages.

The article class suffices for almost any short piece of document typesetting if you omit the title, layout changes, package loading etc.

Clone this wiki locally