computer latex
TRANSCRIPT
-
7/28/2019 Computer Latex
1/16
2 0 0 8 , S t u d e n t L e a r n i n g C e n t r e , C e n t r e f o r A c a d e m i c D e v e l o p m e n t ,
T h e U n i v e r s i t y o f A u c k l a n dW W W : h t t p : / / w w w . s l c . a u c k l a n d . a c . n z
E m a i l : s l c @ a u c k l a n d . a c . n z
C O M P U T E R S K I L L S D E V E L O P M E N T P R O G R A M M E
LaTeX for Document Preparation
-
7/28/2019 Computer Latex
2/16
2008, Student Learning Centre, Ce nt r e f or Ac ad em ic De ve lo pm en t ,T h e University of Auckland.
Page 2
About This Workshop
This workshop is suitable for postgraduate students who would like to use an
alternative to MS Word when authoring their thesis. Students who are required to
typeset complex mathematical formulae and equations in their
assignment/report/thesis, will also benefit from this workshop.
The following contents will be covered:
What is LaTeX? .............................................................................................................. 3
A brief history of LaTex ................................................................................................ 3
To LaTeX or not to LaTeX ............................................................................................. 3
Software for use .......................................................................................................... 4
LaTeX commands ........................................................................................................... 4Documents .................................................................................................................... 4
Creating a document ................................................................................................... 4
Creating a title ............................................................................................................ 5
Structuring a document ............................................................................................... 6
Inserting a table of contents ....................................................................................... 7
Environment .................................................................................................................. 7
Editing ........................................................................................................................... 8
Inserting white space .................................................................................................. 8
Inserting a comment ................................................................................................... 8Formatting text ............................................................................................................ 8
Inserting special characters ...................................................................................... 11
Aligning paragraphs .................................................................................................. 11
Inserting a list ........................................................................................................... 11
Inserting a quote or quotation ................................................................................... 12
Inserting a footnote ................................................................................................... 13
Inserting a table ........................................................................................................ 13
Typesetting Mathematics ............................................................................................. 14
On-line Resources ........................................................................................................ 15
-
7/28/2019 Computer Latex
3/16
2008, Student Learning Centre, Ce nt r e f or Ac ad em ic De ve lo pm en t ,T h e University of Auckland.
Page 3
What is LaTeX?
LaTeX is a high-quality typesetting system. It is especially good at typesetting
mathematical formulae and expressions; it features the production of professional-
looking technical and scientific documentations.
A brief history of LaTeX
Donald E. Knuth Stanford University The Art of Computer Programming Created TEX
1977 - 1989 Development of TEX
Leslie Lamport LaTeX 1984 Extensions to TEX Easier than TEX Focus on the structure of the document
Standard way to use TEX
In 1977, Donald E. Knuth started writing a TEX typesetting engine, which was targeted
at typesetting mathematical formulae and expressions. The TEX engine had been
continuously improved in a decade. It was renowned for its stability and portability.
In 1984, Leslie Lamport started to write LaTeX as an extension to the TEX engine. Since
then, thanks to its high typographical quality, LaTex has become widely used in the
science community.
To LaTeX or not to LaTeX
You may ask why use LaTeX when we have word processors. Here are the answers:
LaTeX is free and runs on many platforms
LaTeX is the best tool available for mathematical layout
LaTeX focuses on structure which helps document development
LaTeX works well for large documents, and since LaTeX documents are in plain
ASCII format, it is very small and easy to transfer via the Internet.
LaTeX automatically generates table of contents, lists of figures, lists of tables,
index, glossaries and bibliography
-
7/28/2019 Computer Latex
4/16
2008, Student Learning Centre, Ce nt r e f or Ac ad em ic De ve lo pm en t ,T h e University of Auckland.
Page 4
If you are sure that you will never need to typeset long document, publish a book in the
scientific community, typeset mathematical formulae or expressions, then you probably
dont need to learn LaTeX. You will be happier to keep working in Word.
Software for use
LaTeX can be downloaded from http://www.latex-project.org/ftp.html . However, as
LaTeX is not a stand-alone typesetting program in itself, but document preparation
software that runs on top of Donald E. Knuth's TEX typesetting system, the easiest (and
free) package to download and install is the latest proTeXt system, which contains a full
TeX system (now called Texmaker), including LaTeX. Read the instructions for
installation very carefully before you install it.
Once you have installed Texmaker, you can use it to create and compile LaTeX
documents. You also need to install GSview in order to view the compiled documents.
You may also use the fol lowing software in order to use LaTeX:
WinEdt,http://www.winedt.com/
TeXnicCenter,http://www.toolscenter.org/
LaTeX commands
Commands are used in LaTeX to instruct it how to typeset something.
Commands have the format:
They begin with a backslash (\) and the command name, followed by optional parts in
square brackets and compulsory parts in curly braces.
It is hard to memorise all LaTeX commands. What we usually do is looking up the syntax
of the commands from LaTeX documentation or references when we need them.
Document structure
Creating a document
The basic structure of a LaTeXdocument is:
\commandname[options]{argument}
\documentclass[options]{format}\begin{document}\end{document}
http://www.latex-project.org/ftp.htmlhttp://www.latex-project.org/ftp.htmlhttp://www.winedt.com/http://www.winedt.com/http://www.winedt.com/http://www.toolscenter.org/http://www.toolscenter.org/http://www.toolscenter.org/http://www.toolscenter.org/http://www.winedt.com/http://www.latex-project.org/ftp.html -
7/28/2019 Computer Latex
5/16
2008, Student Learning Centre, Ce nt r e f or Ac ad em ic De ve lo pm en t ,T h e University of Auckland.
Page 5
A common document format is article. It may also be report, book, letter and
slides. The options parameter consists of a comma-separated list of options. The
common usages of these are the page size (usually a4paper or letterpaper) and the
page layout (landscape or portrait). For example:
The region between the \documentclass and \begin{document} is called the
document preamble and usually consists of a series of extension package inclusions of
the form
The region between \begin{document} and \end{document} is called the
document body. It contains the text to be typeset.
Creating a title
The commands required to create a title include:
\title{title goes here}
\author{author goes here}
\date{date goes here}
Once the information has been defined, insert the command \maketitle.
\documentclass[a4paper]{article}\begin{document}This is my first LaTeX document.\end{document}
\documentclass[a4paper]{article}\begin{document}...\end{document}
\usepackage{package-name}
-
7/28/2019 Computer Latex
6/16
2008, Student Learning Centre, Ce nt r e f or Ac ad em ic De ve lo pm en t ,T h e University of Auckland.
Page 6
Structuring a document
A document can consist of a number of sections and subsections, numbered or
unnumbered. Numbered sections are declared using the \section{section-name}
command, and numbered subsections are declared using the
\subsection{subsection-name} command. Unnumbered sections and
subsections can be declared using the \section*{section-name} and
\subsection*{subsection-name} commands.
Numbered sections and subsections can be cross-referenced in the document. To do
this, the section or subsection declaration must be followed by a \label{label-
name} declaration. Labelled sections can then be referenced from anywhere in the
document using the \ref{label-name} command using the label. When the
document is typeset, the label is replaced by the section number.
\documentclass[a4paper]{article}\begin{document}\title{My First LaTeX Document}\author{Karen Li}\date{2008}\maketitleThis is my first LaTeX document.\end{document}
\documentclass[a4paper]{article}\begin{document}\title{My First LaTeX Document}\author{Karen Li}\date{2008}\maketitleThis is my first LaTeX document. Section \ref{sec:Doc} discusses LaTeXdocuments.\section{Documents} \label{sec:Doc}\subsection{Creating a document}\end{document}
-
7/28/2019 Computer Latex
7/16
2008, Student Learning Centre, Ce nt r e f or Ac ad em ic De ve lo pm en t ,T h e University of Auckland.
Page 7
Inserting a table of contents
The \tableofcontentscommand is used to generate a table of contents.
Environment
In LaTeX, changes to the text need to be applied within an environment. Environments
are like paragraphs.
Each environment begins and ends as:
An example environment is the verbatim environment.
The verbatim environment reproduces text exactly as it appears, using a typewriter font.
No LaTeX commands can be used in verbatim.
\documentclass[a4paper]{article}\begin{document}The following commands are used in LaTeX.\begin{verbatim}Use the \begin{verbatim} command to start a verbatim environment.\end{verbatim}\end{document}
\documentclass[a4paper]{article}\begin{document}\title{My First LaTeX Document}\author{Karen Li}\date{2008}\maketitleThis is my first LaTeX document.\tableofcontents\section{Documents}\subsection{Creating a document}\end{document}
\begin{environmentname}...\end{environmentname}
-
7/28/2019 Computer Latex
8/16
2008, Student Learning Centre, Ce nt r e f or Ac ad em ic De ve lo pm en t ,T h e University of Auckland.
Page 8
You will see a lot of other environments in this document, which are used to format
paragraphs, insert lists and tables, and display mathematical equations.
Editing
Inserting white space
White space can be inserted in a document by using the Space key, Tab key, or the
Enter key. But LaTeX typesets two or more consecutive whitespace characters to a
single space. To add a paragraph, leave a blank line in the input. To add a line break,
use the command \\.
\documentclass[a4paper]{article}\begin{document}The first paragraph.
The second paragraph.\\The third paragraph.\end{document}
Inserting a comment
Comments are ignored when a document is typeset. They are used to add readability for
the document readers. Comments start with the % character.
Formatting text
Text styles
The following commands are used to set text styles:
\textbf{bold text}
% Comments are ignored when a document is typeset.% They are used to add readability.
-
7/28/2019 Computer Latex
9/16
2008, Student Learning Centre, Ce nt r e f or Ac ad em ic De ve lo pm en t ,T h e University of Auckland.
Page 9
\textit{italict text}
\textsl{slanted text }
\textsf{sans-serif text}
\textrm{plain roman text}
\texttt{typewriter text}
\textsc{SMALL CAPITALS TEXT}
\documentclass[a4paper]{article}\begin{document}\textbf{bold}\textit{italic}\textsl{slanted}\textsf{sans-serif}
\textrm{plain roman}\texttt{typewriter text}\textsc{small capitals}\end{document}
Font styles
Font styles can be set in two forms:
1. Declarative form
Set style from this point forward using one of the font style commands listed
below.
2. Environmental form
Create an environment that uses this style.
The following commands are used to set font styles:
\bfseriesBold
\mdseriesNormal weight (i.e. not bold)
\itshapeItalic
\slshapeSlanted
\upshapeUpright (opposite of slanted}
\scshapeSmall Capitals
\rmfamilySerif (roman)
-
7/28/2019 Computer Latex
10/16
2008, Student Learning Centre, Ce nt r e f or Ac ad em ic De ve lo pm en t ,T h e University of Auckland.
Page 10
\sffamilySans-serif
\ttfamilyMonospace (typewriter)
\documentclass[a4paper]{article}\begin{document}%Environment form\begin{itshape}This text is italic.\end{itshape}%Declarative form\scshape
All text from this point forward will be small capitals.\end{document}
Font Size
The following commands are used to set font size:
\tiny \scriptsize \footnotesize\small \normalsize \large\Large \LARGE \huge\Huge
Note: These commands only apply within the curly braces. They work with the
declarative forms for font style too.
\documentclass[a4paper]{article}\begin{document}{\small This text is small}{\Large \itshape This text is large and italic}{\tiny \textit{This text will be tiny and italic} This text will betiny, but not italic.}\end{document}
Emphasis
The command to emphasise a word is:
\emph{text to be emphasised}
\documentclass[a4paper]{article}\begin{document}You need to practise \emph{a lot} in order tolearn \emph{LaTeX}.\end{document}
-
7/28/2019 Computer Latex
11/16
2008, Student Learning Centre, Ce nt r e f or Ac ad em ic De ve lo pm en t ,T h e University of Auckland.
Page 11
Inserting special characters
The following characters need to be inserted in a special way.
These characters can be printed in a document by adding a backslash as the prefix,
except that the $\backslash$command needs to be used to print a \:
\documentclass[a4paper]{article}
\begin{document}$\backslash$ \$ \% \^ \& \_ \~ \# \{ \}\end{document}
Aligning paragraphs
The flushleft environment is used to align a paragraph to the left.
The flushright environment is used to align a paragraph to the right.
The center environment is used to align a paragraph to the centre.
\documentclass[a4paper]{article}\begin{document}\begin{center}Student Learning Centre (SLC) motto:\\Study smarter, not harder,\\to achieve your academic potential!\end{center}\end{document}
Inserting a list
To insert an unordered list (list that uses bullet points rather than numbers), use theitemize environment. The \item command is used to add an item in the list.
\documentclass[a4paper]{article}\begin{document}\begin{itemize}\item Yesterday\item Today\item Tomorrow\end{itemize}\end{document}
\ $ % ^ & _ ~ # { }
-
7/28/2019 Computer Latex
12/16
2008, Student Learning Centre, Ce nt r e f or Ac ad em ic De ve lo pm en t ,T h e University of Auckland.
Page 12
To insert an ordered list (list that is numbered), use the enumerate environment. The
\item command is used to add an item in the list.
\documentclass[a4paper]{article}\begin{document}\begin{enumerate}
\item Yesterday\item Today\item Tomorrow\end{enumerate}\end{document}
To insert a description list (list that is used to define terms), use the description
environment. The \item command is used to add an item in the list.
\documentclass[a4paper]{article}\begin{document}\begin{description}\item[Yesterday] A good day
\item[Today] A better day\item[Tomorrow] A day even better\end{description}\end{document}
Inserting a quote or quotation
The quote environment is used for inserting short quotes. The entire quote is indented;
the first line of the quote is not indented .
The quotation environment is used for longer quotes. The entire quote is indented;
the first line of the quote is also indented.
\documentclass[a4paper]{article}\begin{document}\begin{quote}Life itself cannot give you joy. Unless you really will it.Life just gives you time and space. Its up to you to fill it.\end{quote}\end{document}
\documentclass[a4paper]{article}\begin{document}\begin{quotation}Life itself cannot give you joy. Unless you really will it.Life just gives you time and space. Its up to you to fill it.\end{quotation}\end{document}
-
7/28/2019 Computer Latex
13/16
2008, Student Learning Centre, Ce nt r e f or Ac ad em ic De ve lo pm en t ,T h e University of Auckland.
Page 13
Inserting a footnote
Footnotes are created in the text as you type them using
\footnote{footnote text}
\documentclass[a4paper]{article}\begin{document}\begin{quotation}"They misunderestimated me. \footnote{US President George W. Bush (November6, 2000 in Bentonville, Arkansas)}"\end{quotation}\end{document}
Inserting a table
The tabular environment is used for inserting tables.
\begin{tabular}[pos]{cols}
column 1 entry & column 2 entry ... & column n entry \\
.
.
.
\end{tabular}
The column formatting can be specified using
l - A column of left-aligned items.
r - A column of right-aligned items.
c - A column of centred items.
| - A vertical line the full height and depth of the environment.
The \hline command draws a horizontal line to the width of the table.
\documentclass[a4paper]{article}
\begin{document}\begin{tabular}{| l | c | r |}\hline
Name & Phone Number & Address \\\hlineKaren & 88964 & 11 Symonds Str \\Richard & ????? & ?? \\\hline\end{tabular}\end{document}
-
7/28/2019 Computer Latex
14/16
2008, Student Learning Centre, Ce nt r e f or Ac ad em ic De ve lo pm en t ,T h e University of Auckland.
Page 14
Typesetting Mathematics
There are three ways to typeset mathematics:
1. Inline text enclosed by $ ... $: puts the maths inline within a paragraph
2. displaymath environment: centres the maths on a line of its own
3. equation environment: centres the maths on a line of its own and Numbers
the maths with an equation number
The equation $x = y$is a simple equation.
The equation:\begin{displaymath}
\sum^{n}_{i =1}{i} =\frac{n(n + 1)}{2}\end{displaymath}is a simple equation.
The equation:\begin{equation}x = y\end{equation}is a simple equation.
There are too many mathematics commands to memorise. We just need to look up the
commands when we need them.
The following table lists some of the most commonly used commands.
Command Example Output
^ 2^{10}
_ p_0
\sqrt \sqrt{x^2 + y^2}
\frac{numerator}
{denominator}2\frac{1}{2}
\sum \sum_{i=1}^{n}i
-
7/28/2019 Computer Latex
15/16
2008, Student Learning Centre, Ce nt r e f or Ac ad em ic De ve lo pm en t ,T h e University of Auckland.
Page 15
\pi A = \pi r^2
\int \int^z_{-\infty}
On-line Resources
LaTeX Project Homepage:http://www.latex-project.org/
UOA LaTeX resources:http://www.stat.auckland.ac.nz/~smiller/latex
Web site that allows you to try it out:
http://sciencesoft.at/index.jsp?link=latex&size=1280&js=1&lang=en
FREE stuff for Beginners
o The (Not So) Short Introduction to LATEX2:
http://www.ctan.org/tex-archive/info/lshort/english/
o Using Imported Graphics in LATEX2:
ftp://ctan.tug.org/tex-archive/info/epslatex.pdf
o LATEX2 for authors:
ftp://ftp.tex.ac.uk/tex-archive/macros/latex/base/usrguide.tex
o Beginners LATEX:
http://www.silmaril.ie/downloads/documents/beginlatex.pdf
Beginners to Intermediate Users
o LaTeX: A document Preparation System, Users guide and Reference
manual; Leslie Lamport (US$40)
Beginners to Advanced Users
o The LaTeX Companion. Michel Goossens, Frank Mittelbach, Alexander
Samarin. (US$40.)
o The Latex Web Companion: Integrating Tex, Html and Xml. Michel Goossens
et. al. (US$40)
o The LaTeX Graphics Companion: Illustrating Documents with TeX and
Postscript(R) Michel Goossens et. al. (US$48)
Advanced Users
o The TEXbook; Donald Ervin Knuth (US$43)
http://www.latex-project.org/http://www.latex-project.org/http://www.latex-project.org/http://www.stat.auckland.ac.nz/~smiller/latexhttp://www.stat.auckland.ac.nz/~smiller/latexhttp://www.stat.auckland.ac.nz/~smiller/latexhttp://sciencesoft.at/index.jsp?link=latex&size=1280&js=1&lang=enhttp://sciencesoft.at/index.jsp?link=latex&size=1280&js=1&lang=enhttp://www.ctan.org/tex-archive/info/lshort/english/http://www.ctan.org/tex-archive/info/lshort/english/ftp://ctan.tug.org/tex-archive/info/epslatex.pdfftp://ctan.tug.org/tex-archive/info/epslatex.pdfftp://ftp.tex.ac.uk/tex-archive/macros/latex/base/usrguide.texftp://ftp.tex.ac.uk/tex-archive/macros/latex/base/usrguide.texhttp://www.silmaril.ie/downloads/documents/beginlatex.pdfhttp://www.silmaril.ie/downloads/documents/beginlatex.pdfhttp://www.silmaril.ie/downloads/documents/beginlatex.pdfftp://ftp.tex.ac.uk/tex-archive/macros/latex/base/usrguide.texftp://ctan.tug.org/tex-archive/info/epslatex.pdfhttp://www.ctan.org/tex-archive/info/lshort/english/http://sciencesoft.at/index.jsp?link=latex&size=1280&js=1&lang=enhttp://www.stat.auckland.ac.nz/~smiller/latexhttp://www.latex-project.org/ -
7/28/2019 Computer Latex
16/16
2008, Student Learning Centre, Ce nt r e f or Ac ad em ic De ve lo pm en t ,T h e University of Auckland.
Page 16
TeXPoint
TeXPoint,http://raw.cs.berkeley.edu/texpoint/index.htm , is a LaTeX add-in for
PowerPoint. It is essentially a set of PowerPoint macros which allows you to typeset
LaTeX equations within PowerPoint. Why do you want to do that? Bruce Tsai has put
up a set of PowerPoint slides at
http://www.public.iastate.edu/~aero492/notes/Intro_to_TeXPoint.ppt , which
includes comparison between equations typeset by Microsoft Equation Editor and
LaTeX. Once you get used to LaTeX mathematics symbols and equations, you will
not stand on the ugly symbols and equations produced by a certain equation editor.
pdfscreen
Once you become very confident with L aTeX, you may want to try pdfscreen,
http://www.river-valley.com/download/ . It is written by someone from theEconomics Department at the University of Auckland. You may need to, however, do
some programming to change pdfscreen.sty to suit your needs though.
http://raw.cs.berkeley.edu/texpoint/index.htmhttp://raw.cs.berkeley.edu/texpoint/index.htmhttp://raw.cs.berkeley.edu/texpoint/index.htmhttp://www.public.iastate.edu/~aero492/notes/Intro_to_TeXPoint.ppthttp://www.public.iastate.edu/~aero492/notes/Intro_to_TeXPoint.ppthttp://www.river-valley.com/download/http://www.river-valley.com/download/http://www.river-valley.com/download/http://www.public.iastate.edu/~aero492/notes/Intro_to_TeXPoint.ppthttp://raw.cs.berkeley.edu/texpoint/index.htm