LaTeX Part 1
-
Upload
awv7t -
Category
Technology
-
view
3.599 -
download
2
description
Transcript of LaTeX Part 1
An Intro to LATEXPart IAn introduction to creating a LATEXdocument
Aubry W. Verret
Brown Science and Engineering Library Research Computing Lab
November 10, 2008
Outline IIntroduction to LATEX
What is LATEX?Why use LATEX?How to Get LATEX
Basic LATEXDocumentExample DocumentMarkup fo Example DocumentBasic LATEXCommands
Special LATEXcharacters
CompilingHow LATEXWorksHow to Compile
FilesCLS filesOutput files
Index and Table of Contents GenerationThe ToC
Outline IIThe Index
Bibliographies.bib filesBibliography StylesCompilingBibliography Assistance
Resources
Preview
What is LATEX?
DefinitionLATEXis a powerful document markup system that uses the TeXtypesetting program.
It is pronounced as ’Lah Tek’ or ’Lay Tek’
Why use LATEX?
I LATEXproduces superior quality documents compared to wordprocessor such as Microsoft Word.
I It offers separation of content and formatting
I Makes it easy to collaborate with others on a document
I Many conferences prefer submissions done in LATEX
How to Get LATEX
There are several distributions of LATEXthat are free to obtain.
I Windows - MikTeX is a common package to use. It is freeand easy to install.Common editors to use are TeXnicCenter, WinShell, and Led.
I Mac - MacTex is the current distribution for Mac users.
I Linux - It is likely that LATEXis already a part of your operatingsystem, but if not you can install Tex live.You can use whatever text editor you would normally prefer touse, Emacs, Vi, etc.
I LATEXis also on all of the Lab computers
Go here for more informationhttp://www.latex-project.org/ftp.html
How to Get LATEX
There are several distributions of LATEXthat are free to obtain.
I Windows - MikTeX is a common package to use. It is freeand easy to install.Common editors to use are TeXnicCenter, WinShell, and Led.
I Mac - MacTex is the current distribution for Mac users.
I Linux - It is likely that LATEXis already a part of your operatingsystem, but if not you can install Tex live.You can use whatever text editor you would normally prefer touse, Emacs, Vi, etc.
I LATEXis also on all of the Lab computers
Go here for more informationhttp://www.latex-project.org/ftp.html
How to Get LATEX
There are several distributions of LATEXthat are free to obtain.
I Windows - MikTeX is a common package to use. It is freeand easy to install.Common editors to use are TeXnicCenter, WinShell, and Led.
I Mac - MacTex is the current distribution for Mac users.
I Linux - It is likely that LATEXis already a part of your operatingsystem, but if not you can install Tex live.You can use whatever text editor you would normally prefer touse, Emacs, Vi, etc.
I LATEXis also on all of the Lab computers
Go here for more informationhttp://www.latex-project.org/ftp.html
How to Get LATEX
There are several distributions of LATEXthat are free to obtain.
I Windows - MikTeX is a common package to use. It is freeand easy to install.Common editors to use are TeXnicCenter, WinShell, and Led.
I Mac - MacTex is the current distribution for Mac users.
I Linux - It is likely that LATEXis already a part of your operatingsystem, but if not you can install Tex live.You can use whatever text editor you would normally prefer touse, Emacs, Vi, etc.
I LATEXis also on all of the Lab computers
Go here for more informationhttp://www.latex-project.org/ftp.html
How to Get LATEX
There are several distributions of LATEXthat are free to obtain.
I Windows - MikTeX is a common package to use. It is freeand easy to install.Common editors to use are TeXnicCenter, WinShell, and Led.
I Mac - MacTex is the current distribution for Mac users.
I Linux - It is likely that LATEXis already a part of your operatingsystem, but if not you can install Tex live.You can use whatever text editor you would normally prefer touse, Emacs, Vi, etc.
I LATEXis also on all of the Lab computers
Go here for more informationhttp://www.latex-project.org/ftp.html
How to Get LATEX
There are several distributions of LATEXthat are free to obtain.
I Windows - MikTeX is a common package to use. It is freeand easy to install.Common editors to use are TeXnicCenter, WinShell, and Led.
I Mac - MacTex is the current distribution for Mac users.
I Linux - It is likely that LATEXis already a part of your operatingsystem, but if not you can install Tex live.You can use whatever text editor you would normally prefer touse, Emacs, Vi, etc.
I LATEXis also on all of the Lab computers
Go here for more informationhttp://www.latex-project.org/ftp.html
Basic LATEXDocument
The basic LATEXdocument consists of a preamble, a body, and anending.
A Basic LATEXDocument
Example Document
Aubry W. Verret
November 7, 2008
Hello World!
1
Markup for a Basic LATEXDocument
\ d o c u m e n t c l a s s { a r t i c l e }\ t i t l e {A B a s i c \LaTeX Document}\ a u t h o r {Aubry W. V e r r e t }\ da te {November 2008}\ b e g i n {document}\ m a k e t i t l e
H e l l o World !
\end{document}
Basic LATEXcommands: Preamble
LATEXdocuments begin with a preamble:
I \documentclass{}
I \title{}
I \author{}
I \date{}
Basic LATEXcommands: Preamble
LATEXdocuments begin with a preamble:
I \documentclass{}
I \title{}
I \author{}
I \date{}
Basic LATEXcommands: Preamble
LATEXdocuments begin with a preamble:
I \documentclass{}
I \title{}
I \author{}
I \date{}
Basic LATEXcommands: Preamble
LATEXdocuments begin with a preamble:
I \documentclass{}
I \title{}
I \author{}
I \date{}
Basic LATEXcommands: Preamble
LATEXdocuments begin with a preamble:
I \documentclass{}
I \title{}
I \author{}
I \date{}
Basic LATEXCommands: Body
The Body of the document:
I \begin{document}
I \maketitleYou can then type the body of your document.No need to indent-this happens automatically.Separate paragraphs by a blank line.The document must end with
I \end{document}
Basic LATEXCommands: Body
The Body of the document:
I \begin{document}
I \maketitleYou can then type the body of your document.No need to indent-this happens automatically.Separate paragraphs by a blank line.The document must end with
I \end{document}
Basic LATEXCommands: Body
The Body of the document:
I \begin{document}
I \maketitle
You can then type the body of your document.No need to indent-this happens automatically.Separate paragraphs by a blank line.The document must end with
I \end{document}
Basic LATEXCommands: Body
The Body of the document:
I \begin{document}
I \maketitleYou can then type the body of your document.No need to indent-this happens automatically.Separate paragraphs by a blank line.
The document must end with
I \end{document}
Basic LATEXCommands: Body
The Body of the document:
I \begin{document}
I \maketitleYou can then type the body of your document.No need to indent-this happens automatically.Separate paragraphs by a blank line.The document must end with
I \end{document}
Other Common Commands
Here are some other commands that you will use often:
I \section
I \subsection
I \chapter
I {\bf text}
I {\it text}
I \smallskip \medskip \bigskip
I \begin{enumerate}...\end{enumerate}
I \begin{itemize}...\end{itemize}
Special Characters
LATEXreserves some characters for special purposes:
\ # $ % & ~ _ ^ { }
These characters cannot be used by themselves in your document.
You can include these characters in your text by using the EscapeCharacter
\
Special Characters
LATEXreserves some characters for special purposes:
\ # $ % & ~ _ ^ { }
These characters cannot be used by themselves in your document.
You can include these characters in your text by using the EscapeCharacter
\
Understanding How LATEXWorks
LATEXtakes in a number of different input files and outputs anumber of different files.
The main input file is the .tex file.
Along with the .tex file, LATEXreads in .cls files and .sty files whichprovide all of the needed formatting information.LATEXoutputs a .dvi file and a .log file
Compiling LATEX
In order to compile your LATEXdocument use the latex command onthe .tex file.
For example, if youare using a unix environment then the command would look like this:
latex name of file.tex
Compiling LATEX
In order to compile your LATEXdocument use the latex command onthe .tex file.
For example, if youare using a unix environment then the command would look like this:
latex name of file.tex
.cls files
.cls files specify the format of a specific type of documentdocument. LATEXcomes with four different document classes:
I book - This is good for writing longer books with manychapters
I report - This is good for longer works like dissertations,theses, short books
I article - This is good for conference presentations, shortreports, shorter documents
I letter - This is a simple way of writing a well-formatted letter.
These are mostly similar with some small differences. For instance,the book class allows for chapters and the article class allows forabstracts.There are also many .sty files that allow for more specificformatting control.
.cls files
.cls files specify the format of a specific type of documentdocument. LATEXcomes with four different document classes:
I book - This is good for writing longer books with manychapters
I report - This is good for longer works like dissertations,theses, short books
I article - This is good for conference presentations, shortreports, shorter documents
I letter - This is a simple way of writing a well-formatted letter.
These are mostly similar with some small differences. For instance,the book class allows for chapters and the article class allows forabstracts.There are also many .sty files that allow for more specificformatting control.
.cls files
.cls files specify the format of a specific type of documentdocument. LATEXcomes with four different document classes:
I book - This is good for writing longer books with manychapters
I report - This is good for longer works like dissertations,theses, short books
I article - This is good for conference presentations, shortreports, shorter documents
I letter - This is a simple way of writing a well-formatted letter.
These are mostly similar with some small differences. For instance,the book class allows for chapters and the article class allows forabstracts.There are also many .sty files that allow for more specificformatting control.
.cls files
.cls files specify the format of a specific type of documentdocument. LATEXcomes with four different document classes:
I book - This is good for writing longer books with manychapters
I report - This is good for longer works like dissertations,theses, short books
I article - This is good for conference presentations, shortreports, shorter documents
I letter - This is a simple way of writing a well-formatted letter.
These are mostly similar with some small differences. For instance,the book class allows for chapters and the article class allows forabstracts.There are also many .sty files that allow for more specificformatting control.
.cls files
.cls files specify the format of a specific type of documentdocument. LATEXcomes with four different document classes:
I book - This is good for writing longer books with manychapters
I report - This is good for longer works like dissertations,theses, short books
I article - This is good for conference presentations, shortreports, shorter documents
I letter - This is a simple way of writing a well-formatted letter.
These are mostly similar with some small differences. For instance,the book class allows for chapters and the article class allows forabstracts.There are also many .sty files that allow for more specificformatting control.
.cls files
.cls files specify the format of a specific type of documentdocument. LATEXcomes with four different document classes:
I book - This is good for writing longer books with manychapters
I report - This is good for longer works like dissertations,theses, short books
I article - This is good for conference presentations, shortreports, shorter documents
I letter - This is a simple way of writing a well-formatted letter.
These are mostly similar with some small differences. For instance,the book class allows for chapters and the article class allows forabstracts.
There are also many .sty files that allow for more specificformatting control.
.cls files
.cls files specify the format of a specific type of documentdocument. LATEXcomes with four different document classes:
I book - This is good for writing longer books with manychapters
I report - This is good for longer works like dissertations,theses, short books
I article - This is good for conference presentations, shortreports, shorter documents
I letter - This is a simple way of writing a well-formatted letter.
These are mostly similar with some small differences. For instance,the book class allows for chapters and the article class allows forabstracts.There are also many .sty files that allow for more specificformatting control.
Output Files
DVIs (device independent) are files that contain a preview of yourdocument once it is compiled. It can be converted to a number ofdifferent formats, such as PDF for printing.
LOG files contain a transcript of the compilation process. Theymostly contain the same information that is printed to the screenduring the process.
How to Generate a Table of Contents
Table of Contents in LATEXcan be generated automatically using the
\tableofcontents command.
Place the command wherever you want the table of contents toappear. This is usually right after the
\maketitle command.
The way
\tableofcontents
works is by taking entries from the sectioning commands. Youmust run the latex command twice to generate the ToC wheneveryou add new entries to it. The first time the entries are recordedon a .toc file. The second time they are actually typeset.
How To Generate Indexes
LATEXcan automatically generate indexes
Include
\usepackage{makeidx}\makeindex
in the preamble.When you encounter a term in your document that you would liketo be indexed, use the
\index{term}term command
You will need to run LATEXtwice in order for the index to appear.Once for the entries to be recorded in a .idx file and twice for theentries to be typeset.
It is possible to create various levels of entries.
Bib files
It is relatively simple to generate bibliographies in LATEXusingbibtex and many different bibliographic formats are available.
Bibliographic entries must be kept in a separate file, the .bib file
This is the basic format for bib file entries:
@BOOK{make up an abbreviation,AUTHOR = "author",TITLE = "book title",PUBLISHER = {who published it},ADDRESS = {where it was published},YEAR = year it was published}
@BOOK{latex,AUTHOR = "Goossens, Michel",TITLE = "The \LaTeX Companion",PUBLISHER = {Addison Wesley Longman, Inc.},ADDRESS = {Reading, MA},YEAR = 1994}
Your document should reference the source as follows:
\cite[p. 24] {latex}
To make the bibliography appear in your document include thesecommands at the end where you want the bibliography to go:
\bibliography{filename}\bibliographystyle{plain}
@BOOK{latex,AUTHOR = "Goossens, Michel",TITLE = "The \LaTeX Companion",PUBLISHER = {Addison Wesley Longman, Inc.},ADDRESS = {Reading, MA},YEAR = 1994}
Your document should reference the source as follows:
\cite[p. 24] {latex}
To make the bibliography appear in your document include thesecommands at the end where you want the bibliography to go:
\bibliography{filename}\bibliographystyle{plain}
@BOOK{latex,AUTHOR = "Goossens, Michel",TITLE = "The \LaTeX Companion",PUBLISHER = {Addison Wesley Longman, Inc.},ADDRESS = {Reading, MA},YEAR = 1994}
Your document should reference the source as follows:
\cite[p. 24] {latex}
To make the bibliography appear in your document include thesecommands at the end where you want the bibliography to go:
\bibliography{filename}\bibliographystyle{plain}
Bibliography styles
There are several different options for the bibliographystylecommand. It is also possible to define the style of the bibliographyusing external custom style files.
Go here for more info on bib styles:
http://amath.colorado.edu/documentation/LaTeX/reference/faq/bibstyles.html#styles
Compiling the bibliography
Compiling a document with a bibliography is a little morecomplicated.
I run latex on the .tex file
I run bibtex on the .tex file
I run latex twice more
The first time you run latex, a .aux file is created which bibtex willsubsequently read. The subsequent latex runs allow latex toresolve all of the references between the document and the bib file.
Each time you add new references to your document you mustrepeat this process.
Bibliography Assistance
You can use an external program to manage your bibliography.
A good program for this is Jabref
I Free
I Detailed editing of entries
I Compatibility with various formats
I Automatic key generation
You can get Jabref here: http://jabref.sourceforge.net/
Where to get Help
There are several different resources for learning LATEXBooks:
I LATEXConcisely by Adrian Johnstone
I The LATEXCompanion by Michel Goossens
I A Guide to LATEXby Melmut Kopka
I LATEXFor Scientists and Engineers by David J. Buerger
I The LATEXGraphics Companion
I The LATEXWeb Companion
Online: There are numerous online tutorials and user guides forLATEX, specific commands, packages, etc.
The Research Computing Lab: You can send questions to methrough our ticket systemhttp://www2.lib.virginia.edu/brown/rescomp/help/index.html
What’s Coming Next?
Intro to LATEXPart 2 will cover:
I Including Notes
I Typesetting Mathematics
I Tables
I Graphics
I Figures
I Presentations