Upload
atira
View
58
Download
4
Embed Size (px)
DESCRIPTION
Mikkel Madsen, 5th semester Data/Electronics. Course on Latex. Welcome. Copy content from DVD to your PC and pass it on You can install while I talk ( see the ” Install Help ” link from the DVD) I will help with installs in ~10 minutes About me : Mikkel Madsen, D/E 5th semester - PowerPoint PPT Presentation
Citation preview
COURSE ON LATEX
Mikkel Madsen, 5th semester Data/Electronics
latex.mikkl.dk – [email protected]
Welcome
Copy content from DVD to your PC and pass it on
You can install while I talk (see the ”Install Help” link from the DVD)
I will help with installs in ~10 minutes About me: Mikkel Madsen, D/E 5th semester You can not learn LaTeX in 1 evening
latex.mikkl.dk – [email protected]
Course Wiki
LATEX.MIKKL.DK Objective – aimed at students here at AAUE,
get you started on report writing Use the site to quickly find examples In case of errors or if you would like something
added to the site, contact us on [email protected]
You are always welcome to send us an e-mail if you have a LaTeX issue (we might not be able to help, but we will try)
These slides are available on the site
latex.mikkl.dk – [email protected]
Program
Intro – Why use LaTeX? – (5 min.) Installation of software – (25 min.) LaTeX (1): Syntax, sections, figures, formula and tables –
(30 min.) Short break – (15 min.) Report structure and template – (15 min.) Version control / SVN – (15 min.) LaTeX (2): Preamble, bibtex, cross-references and FiXme –
(30 min.) Break (Sandwich + soda) / Installation help / Questions –
(30 min.) Practice assignments for those interested – (30-60
minutes)
latex.mikkl.dk – [email protected]
What is LaTeX?
Documents without WYSIWYG (What you see is what you get)
Pronounced ”Lah-tech” Based on the ”TeX” typeset language from
1982 Popular for technical reports and books
latex.mikkl.dk – [email protected]
LaTeX Microsoft Word
Harder to learn Easy to use with WYSIWYG
No WYSIWYG – You can concentrate on content
Most people are familiar with it already
You must ”compile” your document to see the result (this can take up to 2-3 minutes at worst)
Handles large reports with images and cross-references very poorly
Can handle multiple authors well – But this requires the use of SVN
Poor support for multiple authors
Time consuming in the beginning, but more efficient (and satisfying) in the long run
Seems easier to use, but is more time consuming over a longer period of time
latex.mikkl.dk – [email protected]
Program
Intro – Why use LaTeX? – (5 min.) Installation of software – (25 min.) LaTeX (1): Syntax, sections, figures, formula and tables –
(30 min.) Short break – (15 min.) Report structure and template – (15 min.) Version control / SVN – (15 min.) LaTeX (2): Preamble, bibtex, cross-references and FiXme –
(30 min.) Break (Sandwich + soda) / Installation help / Questions –
(30 min.) Practice assignments for those interested – (30-60
minutes)
latex.mikkl.dk – [email protected]
Installation
LaTeX distribution Windows: MiKTeX (Basic Installation) Mac: MacTex
Text editor Windows: TeXnicCenter Mac: TeXShop
PDF viewer PDF X-Change recommended Adobe/other pdf-viewer is fine
latex.mikkl.dk – [email protected]
Program
Intro – Why use LaTeX? – (5 min.) Installation of software – (25 min.) LaTeX (1): Syntax, sections, figures, formula and
tables – (30 min.) Short break – (15 min.) Report structure and template – (15 min.) Version control / SVN – (15 min.) LaTeX (2): Preamble, bibtex, cross-references and FiXme –
(30 min.) Break (Sandwich + soda) / Installation help / Questions –
(30 min.) Practice assignments for those interested – (30-60
minutes)
latex.mikkl.dk – [email protected]
LaTeX Syntax
LaTeX is written in ”.tex” files ”\” (backslash) before a command ”{}” (curly braces) around the text the
command is applied to. E.g.:
”\textit{Italic font}” = Italic font”\textbf{Bold font}” = Bold font
Some editors have buttons that will insert commands for you.
”%” (percent sign) before comments. Comments don’t show up in the compiled PDF.
latex.mikkl.dk – [email protected]
A LaTeX document consists of:
Preamble – defines the style, what packages to be used (packages are used for certain commands and styles – more on this in LaTeX part 2}
\begin{Document}Content goes here!
\end{document}
latex.mikkl.dk – [email protected]
Sections
Numbered sections:\part{Part} (-1) I. Part \chapter{Chapter} (0) 1 Chapter\section{Section} (1) 1.1 Section\subsection{Subsection} (2) 1.1.1 Subsection
Non-numbered sections:\section*{Section}\subsection*{Subsection}Just add ”*” before {}
Figures
Basic float:\begin{figure}[htb] \includegraphics{images/chap1/image.jpg} \end{figure}
h – Heret – topb – bottomp – ”page of floats”H – HERE! Must place figure here! (use sparingly)
latex.mikkl.dk – [email protected]
Figures
With more options:\begin{figure}[htb]
\centering \includegraphics{images/chap1/image.jpg} \caption{This is my caption} \end{figure}
Caption can be above image as well Easy with TeXnicCenter Many examples on latex.mikkl.dk
latex.mikkl.dk – [email protected]
latex.mikkl.dk – [email protected]
Formula
”Inline formula” – together with the text:dollar sign ($) before and after formula.$2*\pi*r$
Numbered/Non-numbered formula:\begin{displaymath} 2*\pi*r \end{displaymath}
\begin{equation} 2*\pi*r \end{equation}
See ”The comprehensive latex symbol list (PDF)” for symbols (link on course wiki)
latex.mikkl.dk – [email protected]
Tables
One of the harder things in LaTeX Basic table:
\begin{tabular}{ l | c || r | } 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\\end{tabular}
Column adjusting & - change columnl – left \\ - change rowc – center \hline – horizontal line between rowsr – right | - Vertical line between columns
latex.mikkl.dk – [email protected]
Tables
Numbered table:\begin{table}
\centering\begin{tabular}{|l|c|c|c|}\hline& Firma 1 & Firma 2 & Firma 3 \\\hlineGrundpris & 3000 & 2800 & 3100 \\\hlineLiftkort & 1000 & 1100 & 1000 \\\hlineSkileje & 750 & 750 &
700 \\\hlineSamlet & 4750 & 4650 & 4800 \\\
hline\caption{Pris for skiferie}
\end{table}
latex.mikkl.dk – [email protected]
Program
Intro – Why use LaTeX? – (5 min.) Installation of software – (25 min.) LaTeX (1): Syntax, sections, figures, formula and tables –
(30 min.) Short break – (15 min.) Report structure and template – (15 min.) Version control / SVN – (15 min.) LaTeX (2): Preamble, bibtex, cross-references and FiXme –
(30 min.) Break (Sandwich + soda) / Installation help / Questions –
(30 min.) Practice assignments for those interested – (30-60
minutes)
latex.mikkl.dk – [email protected]
Program
Intro – Why use LaTeX? – (5 min.) Installation of software – (25 min.) LaTeX (1): Syntax, sections, figures, formula and tables –
(30 min.) Short break – (15 min.) Report structure and template – (15 min.) Version control / SVN – (15 min.) LaTeX (2): Preamble, bibtex, cross-references and FiXme –
(30 min.) Break (Sandwich + soda) / Installation help / Questions –
(30 min.) Practice assignments for those interested – (30-60
minutes)
latex.mikkl.dk – [email protected]
“Includes”
\include{path/to/file}insert all content of ”file.tex” (do not include ”.tex”)
Path is relative to root .tex file E.g.: Our root file ”report.tex is in C:/report
Make includes from index.tex in ”content” folder to chap1.tex in the same folder.
WRONG: \include{C:/report/content/chap1} WRONG: \include{chap1} CORRECT: \include{content/chap1}
latex.mikkl.dk – [email protected]
Report structure
latex.mikkl.dk – [email protected]
Report structure
Make up your own structure to fit your needs and style
Rules of thumb: Remember to make \includes whenever you add a file
to the report Paths are relative to the ROOT file (report.tex) Avoid long file and path names Avoid very large .tex files (problematic with several
authors)
latex.mikkl.dk – [email protected]
Report template
http://latex.mikkl.dk/index.php?title=Fil:Rapportskabelon.zip
Containts the folder structure we just discussed, along with preamble, frontpage and a .tex file with a range of examples.
Let’s test if it compiles correctly!
latex.mikkl.dk – [email protected]
Program
Intro – Why use LaTeX? – (5 min.) Installation of software – (25 min.) LaTeX (1): Syntax, sections, figures, formula and tables –
(30 min.) Short break – (15 min.) Report structure and template – (15 min.) Version control / SVN – (15 min.) LaTeX (2): Preamble, bibtex, cross-references and FiXme –
(30 min.) Break (Sandwich + soda) / Installation help / Questions –
(30 min.) Practice assignments for those interested – (30-60
minutes)
latex.mikkl.dk – [email protected]
Version control
Referred to as ”SVN” or ”Subversion” Awesome tool for cooperative authoring SVN terms:
”Update” – Update my local copy so I have the newest version
”Commit” – Create a new version with my changes ”History” – Lists versions (who changed what file and
when) ”Merge” – If several authors have edited the same file ”Conflict” – If several authors have edited the same
lines of a file ”Revert” – Rollback to a previous version (file or folder)
latex.mikkl.dk – [email protected]
Version control
SVN explained graphically: http://aliensystems.ic.cz/svn.swf
Demo of Commit/Update with TortoiseSVN Handling an SVN conflict SVN server?
latex.mikkl.dk – [email protected]
Program
Intro – Why use LaTeX? – (5 min.) Installation of software – (25 min.) LaTeX (1): Syntax, sections, figures, formula and tables –
(30 min.) Short break – (15 min.) Report structure and template – (15 min.) Version control / SVN – (15 min.) LaTeX (2): Preamble, bibtex, cross-references and
FiXme – (30 min.) Break (Sandwich + soda) / Installation help / Questions –
(30 min.) Practice assignments for those interested – (30-60
minutes)
latex.mikkl.dk – [email protected]
Preamble
The preamble is everything from the start of the Latex source file until the \begin{document} command
Defines commands, styles, etc. Some basic preamble settings: \documentclass[a4paper,openright,final]
{memoir} \usepackage[danish]{babel} \setcounter{secnumdepth}{2} \usepackage{graphicx} \usepackage{tabularx}
latex.mikkl.dk – [email protected]
Labels and Cross-references
\label{my_label_name} \ref{my_label_name} E.g.:
\begin{figure}[htb] **** Image centering, path, caption ***\label{img:duck}
\end{figure} Image ~\ref{img:duck} is a picture of a duck! Output will be: ”Figure 1 is a picture of a duck!”
latex.mikkl.dk – [email protected]
Labels and Cross-references
Agree on a naming scheme for your labels, e.g.:fig:label, tab:label, img:label, math:label, sec:label etc.
Labels are case-sensitive - easier to use all lower case letters
You can NOT have 2 of the same labels References to an unknown label will result in ”??” Files must be compiled several times – LaTeX can’t
know about all labels on the first run-through See the latex.mikkl.dk page on ”TeXnicCenter” for
setup of a build profile that compiles latex, bibtex, latex, latex.
latex.mikkl.dk – [email protected]
Labels and Cross-references
Reference to section:\section{My Section}\label{sec:my_section}Hello!
\section{Another Section}In section ~\ref{sec:my_section} I said ”Hello!”.
latex.mikkl.dk – [email protected]
Bibtex and Citations
Sources are stored in a ”.bib” file with entries like: @article{latexarticle1,
author = ”Mikkel Madsen", title = ”The LaTeX Cookbook", year = ”2010", pages = "342--351" }
Citing a source:\cite{latexarticle1} will output ”[X]” with x being the number of the source.
The bibliography will list your sources under their own number, so readers can consult it for details
latex.mikkl.dk – [email protected]
Bibtex and Citations
See the LaTeX wikibook for bibtex exampleshttp://en.wikibooks.org/wiki/LaTeX/Bibliography_Management
Inserting the bibliography (bib.bib): \bibliography{bib}
Changing style (put this before \bibliography{}):\bibliographystyle{ieeetr}”ieeetr” numbers in order of appearance, for other styles see:http://www.cs.stir.ac.uk/~kjt/software/latex/showbst.html
latex.mikkl.dk – [email protected]
The FiXme package
Add the package in Preamble:\usepackage[footnote,draft,english,silent,nomargin]{fixme}
Add a fixme for stuff that needs to be taken care of, or that other authors must look at.
\fxnote{Note here} – inserts a footnote with your note
\listoffixmes generates a list of fixme’s and their page numbers
For long notes use \anfxnote{summary}{long description}Only the summary appears in \listoffixmes, and the long description is in the footnote.
latex.mikkl.dk – [email protected]
Program
Intro – Why use LaTeX? – (5 min.) Installation of software – (25 min.) LaTeX (1): Syntax, sections, figures, formula and tables –
(30 min.) Short break – (15 min.) Report structure and template – (15 min.) Version control / SVN – (15 min.) LaTeX (2): Preamble, bibtex, cross-references and FiXme –
(30 min.) Break (Sandwich + soda) / Installation help /
Questions – (30 min.) Practice assignments for those interested – (30-60
minutes)
latex.mikkl.dk – [email protected]
Program
Intro – Why use LaTeX? – (5 min.) Installation of software – (25 min.) LaTeX (1): Syntax, sections, figures, formula and tables –
(30 min.) Short break – (15 min.) Report structure and template – (15 min.) Version control / SVN – (15 min.) LaTeX (2): Preamble, bibtex, cross-references and FiXme –
(30 min.) Break (Sandwich + soda) / Installation help / Questions –
(30 min.) Practice assignments for those interested – (30-60
minutes)