LATEX and MiKTEX Introductionjknopper/latex/intro3uur-slides.pdf · LATEX is a set of markup...
Transcript of LATEX and MiKTEX Introductionjknopper/latex/intro3uur-slides.pdf · LATEX is a set of markup...
Where innovation starts
LATEX and MiKTEXIntroduction
http://www.win.tue.nl/∼jknopper/latex/intro
Februari 2012 Jan Willem Knopper ([email protected])
2/87
/ department of mathematics and computer science Februari 2012
Introduction 3
Text, Symbols and Commands 22
Exercise 36
Document Layout 37
Displaying Text 46
Exercise 53
Mathematics 54
Tables 56
Graphics 68
Including programming statements 79
Exercise 82
Contents
3/87
/ department of mathematics and computer science Februari 2012
LATEX is a document preparation system. It is widely used in the fields of math-ematics and natural sciences, but also spreading to many other disciplines.
• LATEX is a set of markup commands used with the powerful typesetting pro-gram TEX.
• totally open software system, free of charge.
• platform independent.
Introduction
3/87
/ department of mathematics and computer science Februari 2012
LATEX is a document preparation system. It is widely used in the fields of math-ematics and natural sciences, but also spreading to many other disciplines.
• LATEX is a set of markup commands used with the powerful typesetting pro-gram TEX.
• totally open software system, free of charge.
• platform independent.
LATEX is no word processor! LATEX stimulates placing emphasis on content (logi-cal markup) instead of appearance (typographical markup).
Introduction
4/87
/ department of mathematics and computer science Februari 2012
Introduction
4/87
/ department of mathematics and computer science Februari 2012
LATEX editor: WinEdt
Introduction
4/87
/ department of mathematics and computer science Februari 2012
DVI previewer: Yap
Introduction
4/87
/ department of mathematics and computer science Februari 2012
PostScript viewer: GSView
Introduction
4/87
/ department of mathematics and computer science Februari 2012
PDF viewer: Adobe (Acrobat) Reader
Introduction
4/87
/ department of mathematics and computer science Februari 2012
Introduction
5/87
/ department of mathematics and computer science Februari 2012
The LATEX language• LATEX commands always start with a backslash: \
Introduction
5/87
/ department of mathematics and computer science Februari 2012
The LATEX language• LATEX commands always start with a backslash: \
• required command arguments are placed between curly brackets: { }
Introduction
5/87
/ department of mathematics and computer science Februari 2012
The LATEX language• LATEX commands always start with a backslash: \
• required command arguments are placed between curly brackets: { }
• optional command arguments are placed between brackets: [ ]
Introduction
5/87
/ department of mathematics and computer science Februari 2012
The LATEX language• LATEX commands always start with a backslash: \
• required command arguments are placed between curly brackets: { }
• optional command arguments are placed between brackets: [ ]
• comments start with a percentage symbol: %
Introduction
5/87
/ department of mathematics and computer science Februari 2012
The LATEX language• LATEX commands always start with a backslash: \
• required command arguments are placed between curly brackets: { }
• optional command arguments are placed between brackets: [ ]
• comments start with a percentage symbol: %
• LATEX takes care of the spacing between words and paragraphs (just likeHTML).
Introduction
5/87
/ department of mathematics and computer science Februari 2012
The LATEX language• LATEX commands always start with a backslash: \
• required command arguments are placed between curly brackets: { }
• optional command arguments are placed between brackets: [ ]
• comments start with a percentage symbol: %
• LATEX takes care of the spacing between words and paragraphs (just likeHTML).
• the commands \begin{ } and \end{ } create environments.
Introduction
6/87
/ department of mathematics and computer science Februari 2012
A .tex file
\documentclass[options]{document_class}
% preamble
\begin{document}
% document
\end{document}
Introduction
7/87
/ department of mathematics and computer science Februari 2012
A .tex file: intro.tex
\documentclass[12pt]{article}\usepackage[english]{babel}
\begin{document}\section{Introduction}
LaTeX is a document preparation system used tocreate documents of high quality typography.
It is mostly used in the fields of mathematicsand natural sciences, but can in fact be usedfor any type of publication.\end{document}
Introduction
8/87
/ department of mathematics and computer science Februari 2012
MiKTEXMiKTEX is an up-to-date TEX implementation for the Windows operating system.
• can be downloaded from http://www.miktex.org
• contains all LATEX related binaries, likelatex.exe, pdflatex.exe, yap.exe, bibtex.exe,dvips.exe, ps2pdf.exe
• contains all standard packages (will be discussed later)
Introduction
9/87
/ department of mathematics and computer science Februari 2012
• WinEdt – editor
• Yap – DVI previewer
• GSView – PS previewer
Other useful programs:
• Adobe Acrobat or Adobe Reader – view/edit PDF files
• Corel Designer – Create and export EPS Images
• Libre Office.org Draw – Create and export EPS Images
LATEX Related Programs
10/87
/ department of mathematics and computer science Februari 2012
WinEdt
11/87
/ department of mathematics and computer science Februari 2012
WinEdt
12/87
/ department of mathematics and computer science Februari 2012
WinEdt
13/87
/ department of mathematics and computer science Februari 2012
WinEdt
14/87
/ department of mathematics and computer science Februari 2012
WinEdt
15/87
/ department of mathematics and computer science Februari 2012
runs LATEX on the current document. If no errors are found, the re-sulting DVI file will be opened in Yap.
runs Yap on the generated DVI file.
converts DVI to PostScript.
opens the PostScript file in GSView.
runs PDFLATEX on the current document.
opens the PDF document in Adobe Reader.
opens the document in Yap and jumpt to the current location inthe document.
starts BibTEX(for bibliographies).
generates a master index.
removes all generated auxiliary files (DVI, LOG, PDF, BIB, . . .). Onlythe PostScript file will not be deleted.
16/87
/ department of mathematics and computer science Februari 2012
WinEdt
17/87
/ department of mathematics and computer science Februari 2012
Yap
18/87
/ department of mathematics and computer science Februari 2012
double-click on text for inverse search
Yap
19/87
/ department of mathematics and computer science Februari 2012
GSView
20/87
/ department of mathematics and computer science Februari 2012
WinEdt
21/87
/ department of mathematics and computer science Februari 2012
WinEdt
22/87
/ department of mathematics and computer science Februari 2012
A command is an instruction to LATEX to do something special. Three types ofcommand names:
• the single characters # $ & ~ _ ^ % { } all have special meaning
• to print one of these characters, precede it with a backslash:\$ \# \% \^
• the backslash character \ plus a sequence of letters, ending with the firstnon-letter: \large \Large \bfseries
Text, Symbols and Commands
22/87
/ department of mathematics and computer science Februari 2012
A command is an instruction to LATEX to do something special. Three types ofcommand names:
• the single characters # $ & ~ _ ^ % { } all have special meaning
• to print one of these characters, precede it with a backslash:\$ \# \% \^
• the backslash character \ plus a sequence of letters, ending with the firstnon-letter: \large \Large \bfseries
Some commands have a so-called *-form to modify their functionality some-how. Example:
\section*{Introduction}
Text, Symbols and Commands
23/87
/ department of mathematics and computer science Februari 2012
Many commands operate on some piece of text, which then appears as anargument in curly braces following the command name. Examples:
\section{Introduction}
\textbf{bold text}
\begin{document}
Text, Symbols and Commands
23/87
/ department of mathematics and computer science Februari 2012
Many commands operate on some piece of text, which then appears as anargument in curly braces following the command name. Examples:
\section{Introduction}
\textbf{bold text}
\begin{document}
Optional arguments are put into square brackets and mandatory argumentsinto curly brackets:
\documentclass[11pt]{article}
\usepackage[dutch]{babel}
Text, Symbols and Commands
24/87
/ department of mathematics and computer science Februari 2012
EnvironmentsAn environment affects the text within it treating it differently according to theenvironment parameters.
This text will not appear centered.\begin{center}This text will appear centered.This text will appear centered.This text will appear centered.\end{center}This text will not appear centered.
Text, Symbols and Commands
25/87
/ department of mathematics and computer science Februari 2012
DeclarationsA declaration is a command that changes the values or meanings of certainparameters or commands without printing any text. The effect ends when an-other declaration of the same type is encountered.
This text appears normal while \bfseries this textappears boldface.
Text, Symbols and Commands
25/87
/ department of mathematics and computer science Februari 2012
DeclarationsA declaration is a command that changes the values or meanings of certainparameters or commands without printing any text. The effect ends when an-other declaration of the same type is encountered.
This text appears normal while \bfseries this textappears boldface.
When the declaration occurs within an environment or within a { } block, itsscope extends only to until the end of this environment or block.
This text appears normal while {\bfseries this textappears boldface}. This text is normal again.\begin{center}\bfseriesThis text appears bold.\end{center}This text is normal again.
Text, Symbols and Commands
26/87
/ department of mathematics and computer science Februari 2012
Loading PackagesA package is a set of LATEX commands (or symbols, environments, declarations)stored in a file with the extension .sty. To invoke a package, simply call
\usepackage{package_name}
in the preamble!Example: LATEX does not have a command to include graphics, so if we wantto include graphics in our document, we should load the package graphicxwhich defines a new command \includegraphics.
Text, Symbols and Commands
27/87
/ department of mathematics and computer science Februari 2012
Special Characters – SpacesLATEX takes care of spacing in your document. The following two texts appearexactly the same in the DVI file:
\section{Introduction}
LaTeX is a document preparation system.It is widely used in the fields of mathematicsand natural sciences, but also spreading tomany other disciplines.
\section{Introduction}LaTeX is adocument preparation system. It iswidely used in the fieldsof
mathematics and naturalsciences,but also spreading to many other disciplines.
Text, Symbols and Commands
28/87
/ department of mathematics and computer science Februari 2012
Special Characters – SpacesSome rules:
• one blank is the same as a thousand, only the first one counts.
• blanks at the beginning of an input line are ignored.
• blanks terminating a command name are removed.
• the end of a line is treated as a blank.
Text, Symbols and Commands
28/87
/ department of mathematics and computer science Februari 2012
Special Characters – SpacesSome rules:
• one blank is the same as a thousand, only the first one counts.
• blanks at the beginning of an input line are ignored.
• blanks terminating a command name are removed.
• the end of a line is treated as a blank.
To force a space to appear where it would otherwise be ignored: \ .To force a new line: \newline or \\
Text, Symbols and Commands
29/87
/ department of mathematics and computer science Februari 2012
Special Characters – SpacesSpacing of any desired size may be inserted into the text with the commands
\hspace{10cm}\hspace*{-3mm}
\hspace has no effect if it should come at the beginning of a line. The *-formwill insert the spacing no matter where it occurs.
Text, Symbols and Commands
29/87
/ department of mathematics and computer science Februari 2012
Special Characters – SpacesSpacing of any desired size may be inserted into the text with the commands
\hspace{10cm}\hspace*{-3mm}
\hspace has no effect if it should come at the beginning of a line. The *-formwill insert the spacing no matter where it occurs.
Vertical spacing is created using the \vspace command:
\vspace{10cm}\vspace*{-3mm}
Text, Symbols and Commands
29/87
/ department of mathematics and computer science Februari 2012
Special Characters – SpacesSpacing of any desired size may be inserted into the text with the commands
\hspace{10cm}\hspace*{-3mm}
\hspace has no effect if it should come at the beginning of a line. The *-formwill insert the spacing no matter where it occurs.
Vertical spacing is created using the \vspace command:
\vspace{10cm}\vspace*{-3mm}
Further commands for increasing the spacing between paragraphs are:
\smallskip \medskip \bigskip
Text, Symbols and Commands
30/87
/ department of mathematics and computer science Februari 2012
Lengths and unitsLengths consist of a decimal number, followed by a dimensional unit. Someunits:
cm centimeter
mm millimeter
in inch (= 2.54cm)
pt point (1in = 72.27 pt)
em font-specific size: the width of the capital M
ex font-specific size: the height of the letter x
Text, Symbols and Commands
31/87
/ department of mathematics and computer science Februari 2012
Special Characters – Command CharactersAs mentioned before, the characters # $ ~ _ ^ { } % are interpreted ascommands.To print them as text, give a command consisting of \ plus that character:
\# \$ \~ \_ \^ \{ \} \%
# $ ˜ _ ˆ { } %
Text, Symbols and Commands
31/87
/ department of mathematics and computer science Februari 2012
Special Characters – Command CharactersAs mentioned before, the characters # $ ~ _ ^ { } % are interpreted ascommands.To print them as text, give a command consisting of \ plus that character:
\# \$ \~ \_ \^ \{ \} \%
# $ ˜ _ ˆ { } %
To print a backslash, use the command \textbackslash: \
Text, Symbols and Commands
32/87
/ department of mathematics and computer science Februari 2012
Special Characters – AccentsDiacritical marks or accents can be created with LATEX:
\‘e \’e \^o \"o \~o \=o \v{s} \c{c}be\"invloedenhet re\"ele deelCura\c{c}ao
è é ô ö õ o š çbeïnvloedenhet reële deelCuraçao
Text, Symbols and Commands
33/87
/ department of mathematics and computer science Februari 2012
Special CharactersSpecial symbols can be entered directly, but only if the right input encodingis specified. The input encoding depends on the type and language of theoperating system. We have to load the package inputenc to specify the correctencoding:
\usepackage[ansinew]{inputenc}
beïnvloeden, reëel, CuraçaoC ƒ © ¥ §
beïnvloeden, reëel, Curaçao€ ƒ © ¥ §
Text, Symbols and Commands
33/87
/ department of mathematics and computer science Februari 2012
Special CharactersSpecial symbols can be entered directly, but only if the right input encodingis specified. The input encoding depends on the type and language of theoperating system. We have to load the package inputenc to specify the correctencoding:
\usepackage[ansinew]{inputenc}
beïnvloeden, reëel, CuraçaoC ƒ © ¥ §
beïnvloeden, reëel, Curaçao€ ƒ © ¥ §
Please note that some of these characters also require the textcomp package.
Text, Symbols and Commands
34/87
/ department of mathematics and computer science Februari 2012
The Euro Symbol: €
Adobe created a font containing euro symbols which also contains bold, italicand serif versions. To use these symbols, load the package europs. Now wecan use the following commands:
Text, Symbols and Commands
34/87
/ department of mathematics and computer science Februari 2012
The Euro Symbol: €
Adobe created a font containing euro symbols which also contains bold, italicand serif versions. To use these symbols, load the package europs. Now wecan use the following commands:
\EURofc – creates the official Euro symbol: €
Text, Symbols and Commands
34/87
/ department of mathematics and computer science Februari 2012
The Euro Symbol: €
Adobe created a font containing euro symbols which also contains bold, italicand serif versions. To use these symbols, load the package europs. Now wecan use the following commands:
\EURofc – creates the official Euro symbol: €
\EUR – creates a Euro symbol depending on the current text style
Text, Symbols and Commands
34/87
/ department of mathematics and computer science Februari 2012
The Euro Symbol: €
Adobe created a font containing euro symbols which also contains bold, italicand serif versions. To use these symbols, load the package europs. Now wecan use the following commands:
\EURofc – creates the official Euro symbol: €
\EUR – creates a Euro symbol depending on the current text style
Bold: €
Italic: €
Sans-serif: €
Text, Symbols and Commands
35/87
/ department of mathematics and computer science Februari 2012
The dateLATEX contains a macro to print the current date: \today. The format of thedate depends on the language set with the package babel.
\todayFebruary 6, 2012
Text, Symbols and Commands
35/87
/ department of mathematics and computer science Februari 2012
The dateLATEX contains a macro to print the current date: \today. The format of thedate depends on the language set with the package babel.
\todayFebruary 6, 2012
\selectlanguage{dutch}\today6 februari 2012
Text, Symbols and Commands
36/87
/ department of mathematics and computer science Februari 2012
1. create a new LATEX article. Font size: 11pt. Load the package a4wide toadjust the margins.
2. copy-paste the text from snowwhite.txt in the document body and run LATEX.Explain what the error message means and fix the error.
3. right before the error, a Euro symbol occurs. Verify that the symbol is notprinted in the DVI file. Make sure that LATEX also prints the Euro symbol.
4. the last line (The End) should be large and centered.
5. create sections: Introduction, The evil stepmother, The great forest, Theseven dwarfs, The murder of Snow White, The funeral, The prince, and Themarriage.
6. create subsections: The cottage, The dwarfs, The encounter, First attempt,Second attempt, and Third attempt
Exercise
37/87
/ department of mathematics and computer science Februari 2012
Document ClassThe first command in a .tex file determines the global processing format forthe entire document:
\documentclass[options]{class}
Supported classes are book, report, article, letter or slides.
Supported options:
Document Layout
37/87
/ department of mathematics and computer science Februari 2012
Document ClassThe first command in a .tex file determines the global processing format forthe entire document:
\documentclass[options]{class}
Supported classes are book, report, article, letter or slides.
Supported options:
• font sizes: 10pt 11pt 12pt
Document Layout
37/87
/ department of mathematics and computer science Februari 2012
Document ClassThe first command in a .tex file determines the global processing format forthe entire document:
\documentclass[options]{class}
Supported classes are book, report, article, letter or slides.
Supported options:
• font sizes: 10pt 11pt 12pt
• paper size: a4paper letterpaper
Document Layout
37/87
/ department of mathematics and computer science Februari 2012
Document ClassThe first command in a .tex file determines the global processing format forthe entire document:
\documentclass[options]{class}
Supported classes are book, report, article, letter or slides.
Supported options:
• font sizes: 10pt 11pt 12pt
• paper size: a4paper letterpaper
• number of columns: onecolumn twocolumn
Document Layout
37/87
/ department of mathematics and computer science Februari 2012
Document ClassThe first command in a .tex file determines the global processing format forthe entire document:
\documentclass[options]{class}
Supported classes are book, report, article, letter or slides.
Supported options:
• font sizes: 10pt 11pt 12pt
• paper size: a4paper letterpaper
• number of columns: onecolumn twocolumn
• print style: oneside twoside
Document Layout
38/87
/ department of mathematics and computer science Februari 2012
Loading packagesPackages are loaded in the preamble. A package is a set of LATEX commands (orsymbols, environments, declarations) stored in a file with the extension .sty.Important packages:
a4wide uses smaller page margins, which means that more text fits on onepage.
amsmath contains advanced mathematical symbols.
babel loads hyphenation rules for foreign languages.
europs loads the Euro symbol: €.
fancyhdr is used to customise headers and footers.
graphicx defines a command to load external graphics.
hyperref adds interactivity (hyperlinks, bookmarks) to your document.
listings inserting source code with syntax highlighting
Document Layout
39/87
/ department of mathematics and computer science Februari 2012
Paragraph FormattingThe following parameters affect the appearance of a paragraph:
\parskip the distance between paragraphs, usually in units of ex
\parindent the amount of indentation for the first line of a paragraph
Use the \setlength command to change the values of these parameters.
\setlength{\parskip}{1ex}\setlength{\parindent}{0mm}
Document Layout
39/87
/ department of mathematics and computer science Februari 2012
Paragraph FormattingThe following parameters affect the appearance of a paragraph:
\parskip the distance between paragraphs, usually in units of ex
\parindent the amount of indentation for the first line of a paragraph
Use the \setlength command to change the values of these parameters.
\setlength{\parskip}{1ex}\setlength{\parindent}{0mm}
To suppress the indentation for one paragraph, or to force it:
\noindent\indent
Document Layout
40/87
/ department of mathematics and computer science Februari 2012
Parts of the Document – Title Page
\title{Title text}\author{Author names and addresses}\date{Date text}\maketitle
Document Layout
40/87
/ department of mathematics and computer science Februari 2012
Parts of the Document – Title Page
\title{Title text}\author{Author names and addresses}\date{Date text}\maketitle
Use the \and command to define multiple authors:
\author{Jan Willem Knopper\\ [email protected] \andMarko Boon\\ [email protected]}
Document Layout
40/87
/ department of mathematics and computer science Februari 2012
Parts of the Document – Title Page
\title{Title text}\author{Author names and addresses}\date{Date text}\maketitle
Use the \and command to define multiple authors:
\author{Jan Willem Knopper\\ [email protected] \andMarko Boon\\ [email protected]}
Use \date{} to omit the date.
Document Layout
41/87
/ department of mathematics and computer science Februari 2012
Parts of the Document – AbstractThe abstract is produced with the abstract environment:
\begin{abstract}Text for the abstract.\end{abstract}
In document class report the abstract appears on a separate page (withoutpage number).In document class article the abstract appears below the title.
Document Layout
42/87
/ department of mathematics and computer science Februari 2012
Parts of the Document – Sections and chaptersThe following commands produce automatic, sequential sectioning:
\chapter{ } \chapter*{ }\section{ } \section*{ }\subsection{ } \subsection*{ }\subsubsection{ } \subsubsection*{ }
Document Layout
42/87
/ department of mathematics and computer science Februari 2012
Parts of the Document – Sections and chaptersThe following commands produce automatic, sequential sectioning:
\chapter{ } \chapter*{ }\section{ } \section*{ }\subsection{ } \subsection*{ }\subsubsection{ } \subsubsection*{ }
Remarks:
• The command \chapter exists in document classes book and reportonly.
• A * behind the command results in the unnumbered version which will notbe included in the table of contents.
Document Layout
43/87
/ department of mathematics and computer science Februari 2012
Parts of the Document – AppendixAn appendix is introduced with the declaration \appendix
• Resets the section/chapter counter
• Changes the numbering form from numerals to capital letters (A, B, . . . )
• Replaces the word “Chapter” by “Appendix”.
Please note that the actual word “Appendix” is not added to the table of con-tents!
Document Layout
44/87
/ department of mathematics and computer science Februari 2012
Table of ContentsThe table of contents is generated and printed with the command\tableofcontents (normally after title page and abstract).All entries are created automatically, based on the sectioning commands. Youhave to run latex twice to get all references right!
Document Layout
44/87
/ department of mathematics and computer science Februari 2012
Table of ContentsThe table of contents is generated and printed with the command\tableofcontents (normally after title page and abstract).All entries are created automatically, based on the sectioning commands. Youhave to run latex twice to get all references right!
TeXify and PDFTeXifyIf you use the button for (PDF)TeXify instead of (PDF)LaTeX, WinEdt will runLaTeX, BibTeX, makeindex as many times as necessary.
TeXify
PDFTeXify
Document Layout
45/87
/ department of mathematics and computer science Februari 2012
Labels and ReferencesThe command \label{marker} stores the current value of the relevantcounter (section, chapter, equation, figure, table etc.) at that point in the text.To refer to a label, use:
\ref to print the section, chapter, equation, figure or table number.
\pageref to print the page number on which the \label command was is-sued.
Document Layout
45/87
/ department of mathematics and computer science Februari 2012
Labels and ReferencesThe command \label{marker} stores the current value of the relevantcounter (section, chapter, equation, figure, table etc.) at that point in the text.To refer to a label, use:
\ref to print the section, chapter, equation, figure or table number.
\pageref to print the page number on which the \label command was is-sued.
\section{Labels and References\label{labels}}
In section \ref{labels} you will find informationon how to create labels and references in \LaTeX.The sections starts on page \pageref{labels}.
Document Layout
46/87
/ department of mathematics and computer science Februari 2012
Changing Font StyleThe following commands and declarations change the current font style:
Command Declaration Result\emph \em emphasised\textrm \rmfamily Roman font family\texttt \ttfamily Typewriter font family\textsf \sffamily Sans serif font family\textup \upshape Normal, upright font shape\textit \itshape Italic font shape\textsl \slshape Slanted font shape\textsc \scshape SMALL CAPS FONT SHAPE
\textbf \bfseries Boldface font weight\textmd \mdseries normal (medium) font weight
Displaying Text
47/87
/ department of mathematics and computer science Februari 2012
Changing Font Style – Example
This is normal text with one \textit{italic} word.{\sffamily This whole \itshape line is \textbf{sans}serif.}
\textbf{\textit{Bold and italic}}
Do you see the difference?\emph{emphasised}, \textit{italic}, \textsl{slanted}
Displaying Text
47/87
/ department of mathematics and computer science Februari 2012
Changing Font Style – Example
This is normal text with one \textit{italic} word.{\sffamily This whole \itshape line is \textbf{sans}serif.}
\textbf{\textit{Bold and italic}}
Do you see the difference?\emph{emphasised}, \textit{italic}, \textsl{slanted}
This is normal text with one italic word. This whole line is sans serif.Bold and italicDo you see the difference? emphasised, italic, slanted
Displaying Text
47/87
/ department of mathematics and computer science Februari 2012
Changing Font Style – Example
This is normal text with one \textit{italic} word.{\sffamily This whole \itshape line is \textbf{sans}serif.}
\textbf{\textit{Bold and italic}}
Do you see the difference?\emph{emphasised}, \textit{italic}, \textsl{slanted}
This is normal text with one italic word. This whole line is sans serif.Bold and italicDo you see the difference? emphasised, italic, slanted
This is an italic sentence containing an emphasised word.
Displaying Text
48/87
/ department of mathematics and computer science Februari 2012
Font SizeThe font size can be changed using one of the following declarations:
Declaration Result\tiny smallest
\scriptsize very small
\footnotesize smaller
\small small
\normalsize normal
\large large\Large larger\LARGE even larger\huge still larger\Huge largest
Displaying Text
49/87
/ department of mathematics and computer science Februari 2012
ListsThere are three environments available for producing formatted lists: itemize,enumerate and description.
\begin{itemize}\item This is the first item\item This is the second item\item This is an item with a nested list:\begin{itemize}\item This list has different labels.\item Another item.\end{itemize}\item the final item?\item[+] it is even possible to change the label\end{itemize}
Displaying Text
50/87
/ department of mathematics and computer science Februari 2012
Lists – Itemize• This is the first item
• This is the second item
• This is an item with a nested list:
– This list has different labels.
– Another item.
• the final item?
+ it is even possible to change the label
Displaying Text
51/87
/ department of mathematics and computer science Februari 2012
Lists – Enumerate
\begin{enumerate}\item This is the first item\item This is another item \label{lab}\item This is an item with a nested list:\begin{enumerate}\item This list has different labels.\item In this item we refer to item \ref{lab}.\end{enumerate}\item the final item\end{enumerate}
Displaying Text
52/87
/ department of mathematics and computer science Februari 2012
Lists – Enumerate1. This is the first item
2. This is another item
3. This is an item with a nested list:
(a) This list has different labels.
(b) In this item we refer to item 2.
4. the final item
Displaying Text
53/87
/ department of mathematics and computer science Februari 2012
1. add the a4paper option to the document class.
2. use the paragraph formatting commands to set the default paragraph in-dent to 0 and the default paragraph skip to 1ex.
3. use the appropriate author and title commands to create the title.
4. create an abstract environment
5. add a table of contents after the abstract.
6. change the font size of the last line (The End) to Huge.
7. add a numbered list in section 4.2 (The Dwarfs)
Exercise
54/87
/ department of mathematics and computer science Februari 2012
Mathematical environments:
Mathematics
54/87
/ department of mathematics and computer science Februari 2012
Mathematical environments:
• $ ... $mathematics in a line of text (inline).
Mathematics
54/87
/ department of mathematics and computer science Februari 2012
Mathematical environments:
• $ ... $mathematics in a line of text (inline).
• \[ ... \]mathematics in a separate paragraph.
Mathematics
54/87
/ department of mathematics and computer science Februari 2012
Mathematical environments:
• $ ... $mathematics in a line of text (inline).
• \[ ... \]mathematics in a separate paragraph.
• \begin{equation} ... \end{equation}mathematics in a separate paragraph, including equation number.
Mathematics
54/87
/ department of mathematics and computer science Februari 2012
Mathematical environments:
• $ ... $mathematics in a line of text (inline).
• \[ ... \]mathematics in a separate paragraph.
• \begin{equation} ... \end{equation}mathematics in a separate paragraph, including equation number.
• \begin{eqnarray} ... \end{eqnarray}multiline mathematical equations, properly aligned.
Mathematics
55/87
/ department of mathematics and computer science Februari 2012
Example
Everybody knows that $\sin \pi$ is equal to $0$.
\begin{eqnarray*}\lim_{x \rightarrow 0} \frac{\sin x}{x} &=& 1\\\sum_{k=0}^\infty x^k &=& \frac{1}{1-x} \quad (|x|<1)\end{eqnarray*}
Mathematics
55/87
/ department of mathematics and computer science Februari 2012
Example
Everybody knows that $\sin \pi$ is equal to $0$.
\begin{eqnarray*}\lim_{x \rightarrow 0} \frac{\sin x}{x} &=& 1\\\sum_{k=0}^\infty x^k &=& \frac{1}{1-x} \quad (|x|<1)\end{eqnarray*}
Everybody knows that sinπ is equal to 0.
limx→0
sin xx= 1
∞∑k=0
xk=
11− x
(|x | < 1)
Mathematics
56/87
/ department of mathematics and computer science Februari 2012
The environments array and tabular create tables and matrices. The usage ofarray is the same as for tabular, but it can only be used in math mode.
\begin{array}[pos]{cols}rows
\end{array}
\begin{tabular}[pos]{cols}rows
\end{tabular}
The pos argument defines the vertical positioning for the table: t or b (top orbottom)
Tables
57/87
/ department of mathematics and computer science Februari 2012
The cols argument defines the column formatting. The possible formattingsymbols are:
l the column contents are left justified
r the column contents are right justified
c the column contents are centered
p{width } the text in this column is set in a paragraph box of the specifiedwidth.
| draws a vertical line
|| draws a double vertical line
Tables
58/87
/ department of mathematics and computer science Februari 2012
The rows contain the actual entries. Each row is terminated with the \\ com-mand. The column entries are separated by a & symbol.
Tables
58/87
/ department of mathematics and computer science Februari 2012
The rows contain the actual entries. Each row is terminated with the \\ com-mand. The column entries are separated by a & symbol.
The command \hline draws a horizontal line over the full width.The command \cline{m-n} draws a horizontal line from the left of columnm to the right of column n.
Tables
58/87
/ department of mathematics and computer science Februari 2012
The rows contain the actual entries. Each row is terminated with the \\ com-mand. The column entries are separated by a & symbol.
The command \hline draws a horizontal line over the full width.The command \cline{m-n} draws a horizontal line from the left of columnm to the right of column n.
The command \multicolumn{n}{col}{text} creates a table cell thatextends n columns. The column formatting for this cell is defined by col.
Tables
59/87
/ department of mathematics and computer science Februari 2012
Example 1Stand Eredivisie 6 februari 2011
P W D L Pts +/-1 PSV 22 14 5 3 47 58-212 FC Twente 22 14 5 3 47 45-243 Ajax 22 13 5 4 44 44-204 FC Groningen 22 13 4 5 43 49-285 ADO Den Haag 22 11 5 6 38 40-326 AZ 22 10 7 5 37 34-237 Roda JC 22 9 8 5 35 37-308 FC Utrecht 22 10 4 8 34 36-289 Heerenveen 22 8 7 7 31 42-3310 NAC Breda * 22 9 4 9 30 31-3611 NEC 22 6 9 7 27 36-3812 Graafschap 22 6 7 9 25 22-3913 Heracles Almelo 22 6 6 10 24 32-4014 Vitesse 22 5 7 10 22 27-3715 Feyenoord 22 5 6 11 21 25-3916 Excelsior 22 5 4 13 19 25-4517 VVV-Venlo 22 4 1 17 13 22-5118 Willem II 22 1 4 17 7 19-60
Tables
60/87
/ department of mathematics and computer science Februari 2012
Example 1
\begin{tabular}{|l|l|cccc|r|c|}\hline\multicolumn{8}{|c|}{Eredivisie 6 februari 2011} \\\hline& & P & W & D & L & Pts & +/- \\
\hline1 & PSV & 22 & 14 &5 & 3 & 47 & 58-21 \\2 & FC Twente & 22 & 14 &5 & 3 & 47 & 45-24 \\
...
18 & Willem II & 22 & 1 &4 & 17 & 7 & 19-60 \\\hline\end{tabular}
Tables
61/87
/ department of mathematics and computer science Februari 2012
Example 2Model Description Price
APV Desktop: Intel Core i3 530 processor, 3 GBmemory, 500 GB Hard disk, Onboard HD video-card, Dual Layer DVD±ReWriter, excl. OS
€ 399.00
APP5 Desktop DeLuxe: Intel Core i5 750 proces-sor, 4 GB memory, 1000 GB Hard disk, ATIRadeon HD5670 with 512 MB, Dual LayerDVD±ReWriter, excl. OS
€ 699.00
Tables
62/87
/ department of mathematics and computer science Februari 2012
Example 2
\begin{tabular}{lp{0.5\textwidth}r}\bfseries Model & \bfseries Description &\bfseries Price \\[1ex]
APV & \small \textbf{Desktop}: Intel Core i3 530processor, 3~GB memory, 500~GB Hard disk,Onboard HD videocard, Dual Layer DVD$\pm$ReWriter,excl. OS & \EUR{} 399.00 \\
APP5 & \small \textbf{Desktop DeLuxe}: Intel Corei5 750 processor, 4~GB memory, 1000~GB Hard disk,ATI Radeon HD5670 with 512~MB, Dual LayerDVD$\pm$ReWriter, excl. OS & \EUR{} 699.00 \\\end{tabular}
Tables
63/87
/ department of mathematics and computer science Februari 2012
WinEdt has a useful plug-in to insert tables:
Tables
64/87
/ department of mathematics and computer science Februari 2012
WinEdt has a useful plug-in to insert tables:
Tables
65/87
/ department of mathematics and computer science Februari 2012
WinEdt has a useful plug-in to insert tables:
Tables
66/87
/ department of mathematics and computer science Februari 2012
WinEdt has a useful plug-in to insert tables:
Tables
67/87
/ department of mathematics and computer science Februari 2012
Excel to LATEX Add-In1. download the Excel macro: Excel2LaTeX.xla
2. Start Excel and install the Add-in:
• Tools−→ Add-Ins...
• Browse...
• Browse for the Add-In and click Ok
3. Restart Excel
4. A button has been added to the toolbar:
5. Create a table in Excel, select the table and press this button.
6. Copy-paste to WinEdt
Tables
68/87
/ department of mathematics and computer science Februari 2012
Graphics InclusionTo include an external graphics file:
Graphics
68/87
/ department of mathematics and computer science Februari 2012
Graphics InclusionTo include an external graphics file:
• Load the package graphicx in the preamble:
\usepackage{graphicx}
Graphics
68/87
/ department of mathematics and computer science Februari 2012
Graphics InclusionTo include an external graphics file:
• Load the package graphicx in the preamble:
\usepackage{graphicx}
• Include the graphics using this command:
\includegraphics[width=0.7\linewidth]{filename}
Graphics
69/87
/ department of mathematics and computer science Februari 2012
Supported File Formats:EPS PDF JPG GIF PNG
LATEX yes no yes∗ no yes∗
PDFLATEX no yes yes no yes
Please notice: only EPS and PDF are scalable. Use JPG and PNG just for pho-tographs!
Many programs can generate EPS images. Use Corel Designer to export im-ages created in other programs. Copy/Paste the objects in Corel Designer andexport to EPS.
Use EPS2PDF (on your desktop) to convert EPS to PDF.
∗ does not work automatically when working with LATEX. You should enter thecoordinates of the bounding box manually.
Graphics
70/87
/ department of mathematics and computer science Februari 2012
\includegraphics[options]{filename}
Graphics
70/87
/ department of mathematics and computer science Februari 2012
\includegraphics[options]{filename}
When including EPS or PDF files, use the file name without extension!LATEX will take the EPS, PDFLATEX will take the PDF.
Graphics
70/87
/ department of mathematics and computer science Februari 2012
\includegraphics[options]{filename}
When including EPS or PDF files, use the file name without extension!LATEX will take the EPS, PDFLATEX will take the PDF.
Supported options are:
scale=number magnifies the figure by number over its natural size.
width=length specifies the width to which the figure should be scaled
height=length specifies the height to which the figure should be scaled
angle=number rotates the figure counterclockwise over the specified angle(in degrees)
bb=llx lly urx ury enters the coordinates of the bounding box manually.
Graphics
71/87
/ department of mathematics and computer science Februari 2012
You can create a figure environment to create “floating” figures. LATEX will putthe image at the location that you specify, or on the top of the next page if thefigure does not fit at the current page. In a figure environment you can add acaption and a label to refer to the figure.
\begin{figure}[ht]\begin{center}\includegraphics{normal}\end{center}\caption{Two dimensional normal distribution}\label{fig:normal}\end{figure}
Graphics
71/87
/ department of mathematics and computer science Februari 2012
You can create a figure environment to create “floating” figures. LATEX will putthe image at the location that you specify, or on the top of the next page if thefigure does not fit at the current page. In a figure environment you can add acaption and a label to refer to the figure.
\begin{figure}[ht]\begin{center}\includegraphics{normal}\end{center}\caption{Two dimensional normal distribution}\label{fig:normal}\end{figure}
Now we can refer to the image:
See figure \ref{fig:normal}.
Graphics
72/87
/ department of mathematics and computer science Februari 2012
WinEdt has a useful plug-in to insert pictures:
Graphics
73/87
/ department of mathematics and computer science Februari 2012
WinEdt has a useful plug-in to insert pictures:
Graphics
74/87
/ department of mathematics and computer science Februari 2012
WinEdt has a useful plug-in to insert pictures:
Remove absolute path
and extension
Graphics
75/87
/ department of mathematics and computer science Februari 2012
Scalable and non-scalable graphics
O
P
Q
������6
7 ����������6
1
1
Graphics
76/87
/ department of mathematics and computer science Februari 2012
Scalable and non-scalable graphics
O
P
Q
������6
7 ����������6
1
1
Scalable graphics formats:EPS, PDF, WMF, EMF, SVG.
Non-scalable graphics formats:JPG, GIF, BMP, PNG.But also: all scalable formats!
Graphics
77/87
/ department of mathematics and computer science Februari 2012
Scalable Graphics Software• Corel Designer,
• CorelDraw,
• Adobe Illustrator,
• Microsoft Visio,
• Microsoft Office Drawing,
• OpenOffice.org Draw,
• all computer algebra software (Mathematica, Matlab, Maple)
Non-scalable Graphics Software• Adobe PhotoShop,
• Paint Shop Pro,
• MS Paint,
• all digital photo editing software!
Graphics
78/87
/ department of mathematics and computer science Februari 2012
Including JPG/PNG ImagesLATEX (unlike PDFLATEX) cannot determine the bounding box automatically.
JPEG Image, 2304 × 1728 pixels,72dpi, taken with 4.0 megapixel digitalcamera
Graphics
78/87
/ department of mathematics and computer science Februari 2012
Including JPG/PNG ImagesLATEX (unlike PDFLATEX) cannot determine the bounding box automatically.
JPEG Image, 2304 × 1728 pixels,72dpi, taken with 4.0 megapixel digitalcamera
\includegraphics[width=8cm,bb=0 0 2304 1728]{holiday.jpg}
Graphics
79/87
/ department of mathematics and computer science Februari 2012
The package listings formats listings. It defines the following commands:
• \lstlisting{...} for inline programming statements.
• \begin{lstlisting} ... \end{lstlisting} for multi-line list-ings.
• \lstinputlisting{filename} imports a complete source file
Including programming statements
80/87
/ department of mathematics and computer science Februari 2012
Customizing listingsUsing the command \lstset you can customize the language and appear-ance of the listing:
\lstset{language=Java,basicstyle=\color{black}\ttfamily,commentstyle=\color{green}\itshape\ttfamily,keywordstyle=\color{blue}\bfseries\ttfamily,showstringspaces=false,frame=single, % boxed listingsbackgroundcolor=\color{white}
}
Supported languages: too many to mention. Included are Basic, C, C++, Del-phi, Fortran, HTML, Java, Mathematica, Matlab, Pascal, Perl, PHP, SAS, SQL,TeX, VBScript, XML.
Including programming statements
81/87
/ department of mathematics and computer science Februari 2012
Customizing listingsAlternatively, you can specify options like this:
\definecolor{myyellow}{rgb}{1.00,1.00,0.50}\begin{lstlisting}[language=Pascal,
backgroundcolor=\color{myyellow}]readln(N);for i := 1 to N dobeginwriteln(random)
end\end{lstlisting}
Including programming statements
81/87
/ department of mathematics and computer science Februari 2012
Customizing listingsAlternatively, you can specify options like this:
\definecolor{myyellow}{rgb}{1.00,1.00,0.50}\begin{lstlisting}[language=Pascal,
backgroundcolor=\color{myyellow}]readln(N);for i := 1 to N dobeginwriteln(random)
end\end{lstlisting}
readln(N);for i := 1 to N dobeginwriteln(random)
end
Including programming statements
82/87
/ department of mathematics and computer science Februari 2012
1. insert the picture snowwhite.jpg between the title and the abstract.
Exercise
83/87
/ department of mathematics and computer science Februari 2012
• The LaTeX manual, written by Piet van Oostrum. This is available at thesales point of TU/e syllabi. PDF version already on your laptop!
•
A Guide to LaTeX, by Helmut Kopka.ISBN 0-321-17385-6.
•
The LaTeX Companion Second Edition, by Mittelbachand Goossens. ISBN 0-201-36299-6.
• TU/e LaTeX FAQ: http://www.win.tue.nl/latex
• information about a package: Start Menu, MiKTeX group, Documentation,LaTeX Packages Help.
I want to know more about LATEX!!!
84/87
/ department of mathematics and computer science Februari 2012
WinEdt
LATEX Related Programs
85/87
/ department of mathematics and computer science Februari 2012
WinEdt
LATEX Related Programs
86/87
/ department of mathematics and computer science Februari 2012
WinEdt
LATEX Related Programs
87/87
/ department of mathematics and computer science Februari 2012
WinEdt
LATEX Related Programs