latex a short intro to marco d. santambrogio politecnico di milano sala seminari @ deib 2 sept 2015...
TRANSCRIPT
LaTeX
A Short Intro to
Marco D. SantambrogioPolitecnico di Milano
Sala Seminari @ DEIB2 Sept 2015
Ver. 1.0 @ 2/9/15
2
What are TeX and LaTeX?• LaTeX is a typesetting systems suitable for
producing scientific and mathematical documents– LaTeX enables authors to typeset and print their
work at the highest typographical quality.– LaTeX is pronounced “Lay-tech”.– LaTeX uses TeX formatter as its typesetting
engine.
• TeX is a program written by Donald Kunth for typesetting text and mathematical formulas
3
Why Use LaTeX?• Designed by academics and easily accommodates
academic use.• Professionally crafted predefined layouts make a
document really look as if “printed.”• Mathematical symbols and equations are easily
integrated.• Even complex structures such as footnotes,
references, table of contents, and bibliographies can be generated easily.
• Forces author to focus on logical instead of aesthetic structure of a document.
• Creates more beautiful documents.
4
Process to Create a Document Using LaTeX
TeX input filefile.tex
DVI filefile.dvi
Out input filefile.ps or file.pdf
Run LaTeX program
Run Device Driver
Your source LaTeX document
Device independent output
> latex file.tex > xdiv file.dvi > dvips file.dvi> pdflatex file.tex
Unix Commands
runs latex previewercreates .pscreates .pdf directly
Installing LaTeX• In Windows– MiKTeX
• MiKTeX is a typesetting system for the Windows.• Download from www.miktex.org for free• It is generally recommended to install MiKTeX
first, then WinEdt.– WinEdt
• WinEdt is a text editor.• WinEdt creates the source file (.tex and others).• Download from www.winedt.com for free for 30
days.• WinEdt costs $30.
Installing LaTeX• Other text editors– There are other text editors.– Winshell for free (http://www.winshell.de/)– Scientific Workplace
• Combination of LaTeX and Mathematics program• Does a good job of calculating and graphing, very
user friendly, but expensive
• In Mac– TexShop
• Download for free http://www.uoregon.edu/~koch/texshop/
• Includes everything!
7
How to Use LaTeX to Create Documents
• Start with a skeleton document (create it by yourself, get it from you classmates, download it from journals’ website)
• Fill stuff (text, formula, figure, table …) into your skeleton document
• Run LaTeX to generate output and make modifications
• Learn as you go– The not so short introduction to LaTeX2e http://tobi.oetiker.ch/lshort/lshort.pdf– Comprehensive TeX archive network http://www.ctan.org/– Beginning LaTeX http://www.cs.cornell.edu/Info/Misc/LaTeX-Tutorial/LaTeX-Home.html– Google
Basic Document Structure\documentclass [12pt]{article}
\usepackage {color}\usepackage {graphicx}
\begin{document}
\end{document}
Define the types of the document (article, book, thesis …)
Preamble. Incorporate packages or define macros here
Main body, stuff to be printed, title, authors, abstract, sections, references, ….
Basic Document Structure… more details
• The format of a document is pretty simple.– In the preamble
• Documentclass• Packages
– In the front matter• Title/author
– In the body• Contents
– In the back matter• bibliography
Basic Document Structure… more details
• The format of a document is pretty simple.– In the preamble
• Documentclass• Packages
– In the front matter• Title/author
– In the body• Contents
– In the back matter• bibliography
In the Preamble• You specify your document class.– Document classes: letter, article, report,
book, slides(beamer, prosper)• \documentclass[12pt]{article}• Backslash – at the beginning of text markup
command
– Packages: numerous packages are available• \usepackage[margin=1in]{geometry}• \usepackage{setspace}• \usepackage{harvard}
In the Front Matter• \begin{document}• \title{}• \author{}• \maketitle• \begin{abstract}• \end{abstract}• \pagebreak
In the Body• To begin a new section– \section{}
• Similarly, \subsection{}, \subsubsection{}, \subsubsubsection{}
• LaTeX does automatic numbering. If you don’t like it, use section*{}
• \emph{}, \textbf{}. \textit{}• \singlespacing, \doublespacing, \
onehalfspacing• \centering or \begin{centering} & \
end{centering}
Footnotes/Quotes/Equations• \footnote{}
• \begin{quote}, \end{quote}
• Mathematical Equations– Math always in between $ & $
• Alternatively, \begin{equation} & \end{equation}– $ 1+4=5 $– \frac{}{}, \sqrt{}, \sum_{k=1}^{n}– ^{}, _{}– \greek letters (e.g. \alpha or \Alpha)
15
Figures• You can insert figures in pdf, jpg, eps, and
other formats into your document.
• Multiple figures can be inserted using \subfigure
\begin{figure} \centering \includegraphics {name of the figure file} \caption{Put the caption here} \end{figure}
16
Cross Referencing• LaTeX generates numbers for Theorem,
Equation, Section, Figure and other environments automatically.
• You can access them with \label and \ref
\section{Introduction} \label{sec:intro}
….
In Section \ref{sec:intro}, we ….
Citations• \cite{bibtexkey}
• It is more convenient to create a bibliography file, called bibtex file(.bib) and use it as needed.
Bibliography by hand\begin{thebibliography}{} \bibitem[Come95]{Come95} Comer,D. E., {\it Internetworking with TCP/IP:Principles, Protocols and Architecture},volume 1, 3rd edition. Prentice-Hall,1995.\end{thebibliography}
Bibliography using Bibtex• Bibliography information is stored in a *.bib
file, in Bibtex format.
• Include chicago package– \usepackage{chicago}
• Set referencing style– \bibliographystyle{chicago}
• Create reference section by– \bibliography{bibfile with no extension}
In the *.bib file…@book{Come95,author=“D. E. Comer”,title={Internetworking with TCP/IP:
Principles, Protocols and Architecture},publisher=“Prentice-Hall”,year=1995,volume=1,edition=“Third”}
How to cite• Citing references in text– \cite{cuc98} = (Cuce 1998)– \citeN{cru98} = Crud (1998)– \shortcite{tom98} = (Tom, et. al. 1998)
• Creating Bibtex Files– Use Emacs with extensions.– or copy Bibtex entries from bibliography
database.
In the Back Matter • Do not forget bibliography{filename}– Make sure that the bibtex file is saved in the
same location where the main tex file is saved.
• Do not forget \end{document}
23
To Do…• Install all the necessary tools• Try to write your first LaTeX doc• How to create a list?• How to create numbered list?• How to add a table?• How to organize the doc over several files
(e.g. one file per chapter/section)?
24
Credits• PRISM Brownbag Series, Byungwon Woo• Dept. of Applied Math & Statistics, School
of Engineering, University of California Santa Cruz
• Thomas Madsen