You are on page 1of 7

Introduction

StefanWender
Room303S.376(3rd floorComputerSciencebuilding)
Email:s.wender@cs.auckland.ac.nz
Opendoorpolicy

COMPSCI111/111G

Lectures1115
LaTeX today(14.08.)andtomorrow(15.08.)
PowerPoint(19.08.)andPresentationDesign(21.08.)
TestRevision(22.08.)

NoLectures/Labs25th

Anintroductiontopracticalcomputing

29th

August
August
TestonFriday,29th August6:30pm 7:30pm

LATEX
1

LaTeX

Why?

Adocumentpreparationsystem

WhyuseLaTeX whenwehavewordprocessors?

Usedtotypesetadocument

Resultscanlookbetter
Focusonstructurehelpsdocumentdevelopment
Besttoolavailableformathematicallayout
Workswellforlargedocuments
Automaticallygenerates:
Tableofcontents
Listsoffigures
Listsoftables
Index
Glossaries
Bibliography
Freeandrunsonmanyplatforms

LaTeX
Compiler

http://en.wikipedia.org/wiki/LaTeX
14/08/2014

COMPSCI 111/111G - LaTeX 01

14/08/2014

COMPSCI 111/111G - LaTeX 01

Development

AsimpleLaTeXdocument

DonaldKnuth

\documentclass

StanfordUniversity
TheArtofComputerProgramming
CreatedTeXandMETAFONT
1978 1989DevelopmentofTeX

Definesthetypeofdocument
Book
Report
Article
Letter

LeslieLamport

\documentclass[a4paper]{article}

LaTeX1984
ExtensionstoTeX
EasierthanTeX
Focusonthestructureofthedocument
StandardwaytouseTeX

14/08/2014

COMPSCI 111/111G - LaTeX 01

\begin{document}
...
\end{document}

14/08/2014

Addingatitle

COMPSCI 111/111G - LaTeX 01

Exercise

Requirefourcommandstocreateatitle

WhatistheoutputofthefollowingLATEXcode?

\title{ put the title here }


\author{ author goes here }
\date{ date goes here }

\documentclass[a4paper]{article}
\begin{document}
\title{Exercise question}
\author{your name here}
\maketitle
A quick exercise
\end{document}

Oncetheinformationhasbeendefined,insertthetitle
\maketitle
...
\begin{document}
\title{Just a short document}
\author{Stefan Wender}
\date{2014}
\maketitle
This is the document.
\end{document}
14/08/2014

COMPSCI 111/111G - LaTeX 01

14/08/2014

COMPSCI 111/111G - LaTeX 01

Exercise

Comments
Usedtoannotatethedocument
Ignoredbythecompiler
Aimedatotherhumans

% Comments starts with a percentage sign


% All text is ignored until the end of the
% line is reached.

14/08/2014

COMPSCI 111/111G - LaTeX 01

14/08/2014

COMPSCI 111/111G - LaTeX 01

Commands

10

Environments

UsedtotellLaTeXhowtotypesetsomething

Applyachangetothetextwithintheenvironment

Commandsarecasesensitive
Optionalpartsareinsquarebrackets
Compulsorypartsareincurlybraces

Newenvironmentsstartnewparagraphs

\begin{environmentname}
\commandname[options]{argument}
...
\end{environmentname}

14/08/2014

COMPSCI 111/111G - LaTeX 01

11

14/08/2014

COMPSCI 111/111G - LaTeX 01

12

Specialcharacters

Structuringadocument

Charactersthatareusedinthesyntaxofthelanguage

\part{partnamegoeshere}

Can'ttypethesecharactersdirectly
Needaspecialwaytoprintthem
10characters

\chapter{chapternamegoeshere}

\ $ % ^ & _ ~ # { }

\section{sectionnamegoeshere}
\subsection{subsectionnamegoeshere}

\\doesnotprint\
$\backslash$doesprint\
\backslashbyitselfisanerr

\subsubsection{subsubsectionnamegoeshere}

specialescapecharactersforcurlybracestoo
\{for{and\}for}

\paragraph{paragraphnamegoeshere}

14/08/2014

COMPSCI 111/111G - LaTeX 01

13

14/08/2014

Tableofcontents

14

Exercise

Tableofcontentsisautomaticallygenerated

COMPSCI 111/111G - LaTeX 01

ThefollowingLATEXcodecanbeusedtogenerateatableofcontents.
Showwhatthetableofcontentswilllooklike.

Parts
Chapters
Sections
Subsections

\tableofcontents
\section[Short intro]{A short introduction to typesetting in \LaTeX}
\section[Getting started]{Writing your very first document}
\subsection[TeXnicCenter]{Starting the TeXnicCenter application}

Eachcommandhasantableofcontentsoption
Displaysadifferentnameinthetableofcontents
\section[Introduction]{An introduction
to typesetting using the LaTeX language}

14/08/2014

COMPSCI 111/111G - LaTeX 01

15

14/08/2014

COMPSCI 111/111G - LaTeX 01

16

Exercise

Footnotes
Footnotesarecreatedinthetextasyoutypethem
\footnote{ footnote text goes here }

\documentclass[a4paper]{report}
\begin{document}
\title{A very short report}
\author{Stefan Wender}
\date{2014}
\maketitle
This is the document\footnote{Note that the
document is a report} that I am using as an
example.
\end{document}

14/08/2014

COMPSCI 111/111G - LaTeX 01

17

14/08/2014

COMPSCI 111/111G - LaTeX 01

Whitespace

18

Paragraphsandlinebreaks

Whitespacecharacters

LaTeXwillremoveexcesswhitespace

Spacebar
Tab
Linebreak

Needtoexplicitlyincludeparagraphsandlinebreaks

Paragraph
Leaveablanklineintheinput

Twoormoreconsecutivewhitespacecharacters
Linebreak

Reducedtoasinglespace

Usethecommand\\
A

B
D

C
F

A short paragraph.
Another short paragraph.
And\\
some lines\\
that appear sequentially.

A B C D E F

14/08/2014

COMPSCI 111/111G - LaTeX 01

19

14/08/2014

COMPSCI 111/111G - LaTeX 01

20

Quotemarks

Ellipsis

Unidirectionalquotes(")areinadequate

Threedotsinasequence

Usethesymbols`and'forsinglequotes
Usethesymbols``and''fordoublequotes

Usedtoindicatetextthat...hasbeenremoved
Oranunfinished...

Can'tjustusethreefullstopsinarow

He said, ``As they say, 'you win some, you


lose some' ''.

LaTeXwilluseincorrectspacing
Usethe\ldots command

\ldots or so he said.
He said, As they say, you win some, you lose some .

or so he said

14/08/2014

COMPSCI 111/111G - LaTeX 01

21

14/08/2014

Dashes

COMPSCI 111/111G - LaTeX 01

22

Exercise

Hyphen()

CompletetheLaTeX codebelowsothatit canbeusedto


Generate thefollowingpage.

Shortdashtojoindifferentwordstogether
merrygoround

\documentclass[a4paper]{article}
\begin{document}

Endash()
Longerdashusedtoindicatearangeofvalues
pages4550

Em dash()
Verylongdashbetweenwordsorphrases
Therearemanycommandssomemorecomplexthanotherthatareusedin
LaTeX.

\end{document}
14/08/2014

COMPSCI 111/111G - LaTeX 01

23

14/08/2014

COMPSCI 111/111G - LaTeX 01

24

Exercise

Spaces

\documentclass[a4paper]{article}
\begin{document}
\title{Some short quotes}
\author{Goucho Marx}
\date{1890-1977}
\maketitle
\section{Principles}
Those are my principles, and if you don't like them\ldots
well, I have others.

Lineshavetobebrokentowraptext
Trytobreakataspace
Trytobreakatasyllable

Somespaceswedon'twanttobebroken
E.g.betweeninitialsandsurnames

Bad layout

\section{Instructions}
Quote me as saying I was mis-quoted.

The lecturer for this course is S.


T. Wender

Useatilde~tosignifyaspacethatwecan'tbreak

\section{Complaints}
I didn't like the play, but then I saw it under adverse
conditions --- the curtain was up.

The lecturer for this course is


S.~T.~Wender

\end{document}
14/08/2014

COMPSCI 111/111G - LaTeX 01

25

14/08/2014

Emphasis

COMPSCI 111/111G - LaTeX 01

26

References

Emphasis

TherearemanyLaTeX tutorialsontheInternet

\emph{ text to be emphasized here }

http://www.tug.org/interest.html
http://www.latexproject.org/
http://www.ctan.org

It is \emph{very} important to
practice the typesetting commands
so that you don't \emph{forget} them.

Websitethatallowsyoutotryitout
http://sciencesoft.at/latex/?lang=en

Tutorialdocuments
The(notso)shortguidetoLaTeX

HelpwithintheTeXnicCenter application
LaTeX manual

14/08/2014

COMPSCI 111/111G - LaTeX 01

27

14/08/2014

COMPSCI 111/111G - LaTeX 01

28

You might also like