4th Course LaTeX
4th Course LaTeX
DEPARTEMENT OF ANALYSIS
L3-ACL
T. HAFSI
3nd course: Create your document
1) The document
2) Inserting references
3) Practical
The document
To create our own document, we need to go through several steps. We have seen in the
previous courses some necessary concepts for creating the document. We will continue our
course with other tools that are essential in any document.
3
Page formats
❑ There are options for setting the contents of each page in a single column or in two
columns (as in most dictionaries).
❑ This is set by the options
onecolumn twocolumn
❑ The default is onecolumn.
4
Page formats
❑ There is also an option to specify whether the document will be finally printed on just
one side of each paper or on both sides.
❑ The names of the options are
oneside twoside
5
Remarks
✓ The differences is that with the twoside option, page numbers are printed on
the right on odd-numbered pages and on the left on even numbered pages, so that when
these printed back to back
✓ The numbers are always on the outside, for better visibility.
✓ The default is oneside for article, report and letter and twoside for book.
6
Page formats
❑ In the report and book class there is a provision to specify the different chapters.
❑ Chapters always begin on a new page, leaving blank space in the previous page, if
necessary.
❑ With the book class there is the additional restriction that chapters begin only on odd-
numbered pages, leaving an entire page blank, if need be.
❑ Such behavior is controlled by the options:
openany openright
7
Page formats
8
Page formats
✓ There is another provision for formatting the title (the name of the document,
author(s) and so on) of a document with special typographic consideration.
✓ In the article class, this part of the document is printed along with the text following
on the first page
✓ while for report and book, a separate title page is printed.
✓ These are set by the options
notitlepage titlepage
9
Page style
❑ In LATEX parlance, each page has a “head” and “foot” usually containing such
information as the current page number or the current chapter or section.
❑ Just what goes where is set by the command
\pagestyle{...}
where the mandatory argument can be any one of the following styles
plain empty headings myheadings
10
Page style
Plain The page head is empty and the foot contains just the page number, centered
with respect to the width of the text. This is the default for the article class if no
\pagestyle is specified in the preamble.
empty Both the head and foot are empty. In particular, no page numbers are printed.
11
Page style
headings This is the default for the book class. The foot is empty and the head contains
the page number and names of the chapter section or subsection, depending on the
document class and its options as given below :
12
Page style
myheadings The same as headings, except that the ‘section’ information in the head
are not predetermined, but to be given explicitly using the commands \markright or
\markboth.
\markboth{left head{right head} }
\markright{right head}
We can customize the style for the current page only using the command
\thispagestyle{style}
13
Page style
➢ The \markboth command is used with the twoside option with even numbered pages
considered to be on the left and odd numbered pages on the right.
➢ With oneside option, all pages are considered to be right-handed and so in this case,
the command \markright can be used.
14
Page style
✓ The command \markright can be used to override the default head set by the
headings style.
✓ These give only a limited control over the head and foot.
✓ Better customization of the head and foot are offered by the package fancyhdr.
15
Formatting lengths
❑ Each page that LATEX produces consists not only of a head and foot but also a body
containing the actual text.
❑ LATEX uses the width and heights of these parts of the page and various other lengths
such as the left and right margins.
❑ The values of these lengths are set by the paper size options and the page format and
style commands.
16
Formatting lengths
17
Inserting references
LATEX includes features that allow you to easily cite references and create
18
The BiBTeX file
❑ Your BibTeX file contains all the references you want to cite in your document.
❑ It has the file extension .bib.
❑ It should be given the same name as and kept in the same folder as your .tex file.
❑ The .bib file is plain text, it can be edited using Notepad or your LATEX editor.
19
The BiBTeX file
You should enter each of your references in the BibTeX file in the following format:
@article{
Birdetal2001,
Author = {Bird, R. B. and Smith, E. A. and Bird, D. W.},
Title = {The hunting handicap: costly signaling in human foraging strategies},
Journal = {Behavioral Ecology and Sociobiology},
Volume = {50},
Pages = {9-19},
Year = {2001} }
20
Notes
✓ Each reference starts with the reference type (@article in the example above).
✓ Other reference types include @book, @incollection for a chapter in an edited book
and @inproceedings for papers presented at conferences.
✓ The reference type declaration is followed by a curly bracket, then the citation key.
✓ Each reference’s citation key must be unique.
✓ Surround any letters in a journal article title that need to be capitalized with curly
brackets {...}.
21
Inserting the bibliography
✓ Type the following where you want the bibliography to appear in your document
\bibliographystyle{plain}
\bibliography{references}
Where references is the name of your .bib file.
22
Citing references
❑ Type \cite{citationkey} where you want to cite a reference in your .tex document.
❑ If you don’t want an in text citation, but still want the reference to appear in the
bibliography, use \nocite{citationkey}.
❑ To include a page number in your in-text citation put it in square brackets before the
citation key: \cite[p. 215]{citationkey}.
❑ To cite multiple references include all the citation keys within the curly brackets
separated by commas: \cite{citation01,citation02,citation03}.
23
Citations styles
1.Numerical citations
2. Author-date citations
24
1.Numerical citations
Abbrv : The same as plain except the authors’ first names are abbreviated to an initial.
25
1.Numerical citations
Unsrt : The same as plain except the references in the bibliography appear in the order
that the citations appear in the document.
26
2. Author-date citations
❑ Natbib uses the command \citep{...} for a citation in brackets (e.g. [Koppe, 2010])
and \citet{...} for a citation where only the year is in brackets (e.g. Koppe [2010]).
❑ Natbib comes with three bibliography styles: plainnat, abbrvnat and unsrtnat.
27
3. Other bibliography styles
❑ If you want to use a different style (e.g. one provided by the journal you are
submitting an article to) you should save the style file (.bst file) in the same folder as
28
Practical 1
29
Practical 1
➢ Switch to your .tex document and insert \cite, \bibliographystyle and \bibliography
commands in the relevant places.
➢ Typeset your .tex file.
➢ Switch to your .bib file, choose BibTeX from the typeset menu and click the Typeset
button.
➢ Switch to your .tex file and typeset it twice. The in-text citations and reference list
should be inserted.
30
Practical 2
You can do it
31
Thank you for your
attention
32