Formatting
The term formatting is rather broad, but in this case it needs to be as this section will guide you various text, paragraph and page formatting techniques. Formatting tends to refer to most things to do with appearance, it makes the list of possible topics quite eclectic: text style, font, size; paragraph alignment, interline spacing, indents; special paragraph types; list structures; footnotes, margin notes, etc.
A lot of the formatting techniques are required to differentiate certain elements from the rest of the text. It is often necessary to add emphasis to key words or phrases. A numbered or bulleted list is also commonly used as a clear and concise way of communicating an important issue. Footnotes are useful for providing extra information or clarification without interrupting the main flow of text. So, for these reasons, formatting is very important. However, it is also very easy to abuse, and a document that has been over-done can look and read worse than one with none at all.
Text formatting
Quotes
LaTeX treats left and right quotes as different entities. For single quotes, ` (on British keyboards, this symbol is found on the key adjacent to the number 1) gives a left quote mark, and ' is the right. For double quotes, simply double the symbols, and LaTeX will interpret them accordingly. (Although, you can use the " for right double quotes if you wish).
To `quote' in LaTeX | |
To ``quote'' in LaTeX | |
To ``quote" in LaTeX |
The right quote is also used for apostrophe in LaTeX without trouble.
Dots and Dashes
A sequence of three dots is known as an ellipsis, which is commonly used to indicate omitted text. Simply inputting three dots doesn't give the best output because the spacing is not correct. Therefore, you should use \ldots to get the right result.
Ellipsis... | |
Ellipsis \ldots |
LaTeX has three specific types of dashes, each a different size, and each for a different purpose:
Accents
It does not take long before you need to use an accented character within your document. Personally, I find it tends to be names of researchers who I wish to cite which contain accents. It's easy to apply (click on the image for a larger version to see greater detail), although not all are easy to remember!:
Symbols
LaTeX has lots of symbols at its disposal. The majority of them are within the mathematical domain, and future tutorials will cover how to get access to them. For the more common text symbols, use the following commands:
Of course, these are rather boring, and it just so happens that for some more interesting symbols, then the Postscript ZipfDingbats font is available thanks to the pifont. Hopefully, you are beginning to notice now that when you want to use a package, you need to add the declaration to your preamble, in this instance: \usepackage{pifont}. Next, the command \ding{number}, will print the specified symbol.
For this link for a table listing all possible ZapfDingbats symbols (warning: large image!)
Emphasising text
In order to add some emphasis to a word or phrase, the simplest way is to use the \emph{text} command. That's it! See, dead easy.
I want to \emph{emphasize} a word. |
Font styles
I shall really only scratch the surface about this particular field. This section is not about how to get your text in Verdana size 12pt! There are three main font families: roman (such as Times), sans serif (eg Arial) and monospace (eg Courier). You can also specify styles such as italic and bold. The following table lists the commands you will need to access the typical font styles:
You may have noticed the absence of underline. This functionality has to be added with the ulem package. Stick \usepackage{ulem} in your preamble. By default, this overrides the \emph command with the underline rather than the italic style. It is unlikely that you wish this to be the desired effect, so it is better to stop ulem taking over \emph and simply call the underline command as and when it is needed.
- To disable ulem, add \normalem straight after the document environment begins.
- To underline, use \uline{...}.
- To add a wavy underline, use \uwave{...}.
- And for a strike-out \sout{...}.
Finally, there is the issue of size. This to is very easy, simply follow the commands on this table:
Paragraph Formatting
Altering the paragraph formatting is not often required, especially in academic writing. However, it is useful to know, and applications tend to be for formatting text in floats, or other more exotic documents.
Paragraph Alignment
Paragraphs in LaTeX are usually fully justified (i.e., flush with both the left and right margins). For whatever reason, should you wish to alter the justification of a paragraph, there are three environments at hand, and also LaTeX command equivalents.
Alignment | Environment | Command |
---|---|---|
Left justified | flushleft | \raggedright |
Right justified | flushright | \raggedleft |
Center | center | \centering |
All text between the \begin and \end of the specified environment will be justified appropriately. The commands listed are for use within other environments. For example, p (paragraph) columns in tabular.
Paragraph Indents
Paragraph indents are normally fine. The size of the indent is determined by a parameter called \parindent. The default length that this constant holds is set by the document class that you use. It is possible to override using the \setlength command.
\setlength{\parindent}{length} will reset the indent to length.
Be careful, however, if you decide to set the indent to zero, then it means you will need a vertical space between paragraphs in order to make them clear. The space between paragraphs is held in \parskip, which could be altered in a similar fashion as above. However, this parameter is used elsewhere too, such as in lists, which means you run the risk of making various parts of your document look very untidy (that is, even more untidy than this type of paragraph style!) It may be better to use a document class typeset for this style of indentation, such as artikel3.cls (written by a dutch person, translates to article3).
Line Spacing
It's rarely necessary to require anything other than single line spacing. But for those of you who require it, this is how...
- Add \usepackage{setspace} to the document preamble.
- This then provides the following environments to use
within your document:
- doublespace - all lines are double spaced.
- onehalfspace - line spacing set to one-and-half spacing.
- singlespace - normal linespacing.
Special paragraphs
For those of you who have read most/all of the tutorials so far, you will have already come across some of the following paragraph formats. Although seen before, it makes sense to re-introduce here, for the sake of completeness.
Verbatim Environment
This environment was used in an example in the previous tutorial. Everything input between the begin and end commands are processed as if by a typewriter. All spaces and new lines are reproduced as given, and the text is displayed in an appropriate monospace font. Ideal for typesetting program source code, for example.
\begin{verbatim} The verbatim environment simply reproduces every character you input, including all s p a c e s! \end{verbatim} |
Note: once in the verbatim environment, the only command that will be recognised is \end{verbatim}. Any others will be output, verbatim! If this is an issue, then you can use the alltt package instead.
\begin{alltt} Verbatim extended with the ability to use normal commands. Therefore, it is possible to \emph{emphasize} words in this environment, for example. \end{alltt} |
Remember to add \usepackage{alltt} to your preamble to use it though!
Listing Environment
This is also an extension of the verbatim environment. The extra functionality it provides is that it can add line numbers along side the text. The command: \begin{listing}[step]{first line}. The mandatory first line argument is for specifying which line the numbering shall commence. The optional step is the step between numbered lines (the default is 1, which means every line will be numbered).
To use this environment, add \usepackage{moreverb} to the document preamble.
Quote and Quotation Environment
There are two environments available for quoting passages within your own documents, with only a subtle difference between them. The quote environment is designed for a short quotation, or a series of small quotes, separated by blank lines. quotation on the other-hand, is for use with longer quotes, of more than one paragraph. Both are indented on either margin, and you will need to add your own quotation marks if you want them.
See the paras.tex and paras.pdf for examples of these in use.
Abstract Environment
This should be fairly obvious. For academic papers, an abstract is always included at the beginning. It is typically formatted differently from the rest of the text --- indented either side, and a slightly smaller font. At least, that is what the default presentation is like. See the Document structure tutorial, or paras.tex and paras.pdf for examples of using abstract.
Verse Environment
This environment is intended for displaying poetry. I can't really see many people using this within a typical document, however, it won't hurt to briefly explain its usage. As always, as an environment, it needs to \begin and \end. Once in, new stanzas are created with a blank line, and new lines within a stanza are indicated using the newline command, \\. If a line takes up more than one line on the page, then all subsequent lines are indented until explicitly separated with \\.
See the paras.tex and paras.pdf for examples of this in action.
List structures
Lists often appear in documents, especially academic, as their purpose is often to present information in a clear and concise fashion. List structures in LaTeX are simply environments which essentially come in three flavours: itemize, enumerate and description.
All lists follow the basic format:
\begin{list_type} \item The first item \item The second item \item The third etc \ldots \end{list_type}
Itemize
This environment is for your standard bulleted list of items.
\begin{itemize} \item The first item \item The second item \item The third etc \ldots \end{itemize} |
Enumerate
The enumerate environment is for ordered lists, where by default, each item is numbered sequentially.
\begin{enumerate} \item The first item \item The second item \item The third etc \ldots \end{enumerate} |
Description
The description environment is slightly different. You can specify the item label by passing it as an optional argument (although optional, it would look odd if you didn't include it!). Ideal for a series of definitions, such as a glossary.
\begin{description} \item[First] The first item \item[Second] The second item \item[Third] The third etc \ldots \end{description} |
Nested Lists
LaTeX will happily allow you to insert a list environment into an existing one (up to a depth of four). Simply begin the appropriate environment at the desired point within the current list. LaTeX will sort out the layout and any numbering for you.
\begin{enumerate} \item The first item \begin{enumerate} \item Nested item 1 \item Nested item 2 \end{enumerate} \item The second item \item The third etc \ldots \end{enumerate} |
Customising Lists
Customising many things in LaTeX is not really within the beginners domain. Whilst not necessarily difficult, per se, because beginners are already overwhelmed with the array of commands and environments, moving on to more advanced topics runs the risk of confusion.
However, since the tutorial is on formatting, then I shall still include a brief guide on customising lists. Feel free to skip!
Customising Enumerated Lists
The thing people want to change most often with Enumerated lists are the counters. Therefore, to go any further, a brief introduction to LaTeX counters is required. Anything that LaTeX automatically numbers, such as section headers, figures, and itemised lists, there is a counter associated with it that controls the numbering. Each counter also has a default format that dictates how it is displayed whenever LaTeX needs to print it. Such formats are specified using internal LaTeX commands:
Command | Example |
\arabic | 1, 2, 3 ... |
\alph | a, b, c ... |
\Alph | A, B, C ... |
\roman | i, ii, iii ... |
\Roman | I, II, III ... |
\fnsymbol | Aimed at footnotes (see below), but prints a sequence of symbols. |
There are four individual counters that are associated with itemised lists, each one represents the four possible levels of nesting, which are called: enumi, enumii, enumiii, enumiv. Each counter entity holds various bits of information about itself. To get to the numbered element, simply use \the followed immediately (ie no space) by the name of the counter, eg \theenumi. This is often referred to as the representation of a counter.
Now, that's most of the technicalities out of the way. To make changes to the formatting of a given level: \renewcommand{\representation}{\format_command{counter}}. Admittedly, the generic version is not that clear, so a couple of examples will clarify:
%Redefine the first level \renewcommand{\theenumi}{\Roman{enumi}} \renewcommand{\labelenumi}{\theenumi} %Redefine the second level \renewcommand{\theenumii}{\Alph{enumii}} \renewcommand{\labelenumii}{\theenumii}
The method used above first explicitly changes the format used by the counter. However, the element that controls the label needs to be updated to reflect the change, which is what the second line does. Another way to achieve this result is this:
\renewcommand{\labelenumi}{\Roman{enumi}}
This simply redefines the appearance of the label, which is fine, providing that you do not intend to cross-reference to a specific item within the list, in which case the reference will be printed in the previous format. This issue does not arise in the first example.
Customising Itemised Lists
Itemised lists are not as complex as they do not need to count. Therefore, to customise, you simply change the labels. The itemize labels are accessed via \labelitemi, \labelitemii, \labelitemiii, \labelitemiv, for the four respective levels.
\renewcommand{\labelitemi}{\textgreater}
The above example would set the labels for the first level to a greater than (>) symbol. Of course, the text symbols available in LaTeX are not every exciting. Why not use one of the ZapfDingbat symbols, as described in the symbols section.
Footnotes
Footnotes are a very useful way of providing extra information to the reader. It is normally non-essential, and so can be placed at the bottom of the page, which means the main body remains concise.
The footnote facility is easy to use. The command you need is: \footnote{text}. Do not leave a space between the command the word where you wish the footnote marker to appear, otherwise LaTeX will process that space and will leave the output not looking as intended.
Creating a footnote is easy.\footnote{An example footnote.} |
LaTeX will obviously take care of typesetting the footnote at the bottom of the page. Each footnote is numbered sequentially - a process, as you should have guessed by now is automatically done for you.
It is possible to customise the footnote marking. By default, they are numbered sequentially (Arabic). However, without going too much into the mechanics of LaTeX at this point, it is possible to change using the following command (of which needs to be placed at the beginning of the document, or at least before the first footnote command is issued).
\renewcommand{\thefootnote}{\arabic{footnote}} | Arabic numerals, e.g., 1, 2, 3... |
\renewcommand{\thefootnote}{\roman{footnote}} | Roman numerals (lowercase), e.g., i, ii, iii... |
\renewcommand{\thefootnote}{\Roman{footnote}} | Roman numerals (uppercase), e.g., I, II, III... |
\renewcommand{\thefootnote}{\alph{footnote}} | Alphabetic (lowercase), e.g., a, b, c... |
\renewcommand{\thefootnote}{\alph{footnote}} | Alphabetic (uppercase), e.g., A, B, C... |
\renewcommand{\thefootnote}{\fnsymbol{footnote}} | A sequence of nine symbols (try it and see!) |
Margin notes
A dare say that this is a commonly used function, however, I thought I'd include it anyway, as it is simple to use command. \marginpar{margin text} will position the enclosed text on to the outside margin. To swap the default side, issue \reversemarginpar and that move margin notes to the opposite side.
Summary
Phew! What a busy tutorial! A lot of material was covered here, mainly because formatting is such a broad topic. LaTeX is so flexible that I actually only skimmed the surface, as you ca have much more control over the presentation of your document if you wish. Having said that, one of the purposes of LaTeX is to take away the stress of having to deal with the physical presentation yourself, so you need not get too carried away!