360 likes | 509 Views
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
E N D
Mikkel Madsen, 5th semester Data/Electronics Courseon Latex
Welcome • Copycontent from DVD to your PC and pass it on • Youcaninstallwhile I talk (see the ”InstallHelp” link from the DVD) • I willhelpwithinstalls in ~10 minutes • Aboutme: Mikkel Madsen, D/E 5th semester • Youcan not learnLaTeX in 1 evening latex.mikkl.dk – latex@antistof.dk
CourseWiki • LATEX.MIKKL.DK • Objective – aimed at students here at AAUE, getyoustartedonreportwriting • Use the site to quickly find examples • In case of errorsorifyouwouldlikesomethingadded to the site, contactusonlatex@antistof.dk • Youarealwayswelcome to send us an e-mail ifyou have a LaTeXissue (wemight not beable to help, but wewilltry) • These slides areavailableon the site latex.mikkl.dk – latex@antistof.dk
Program • Intro – WhyuseLaTeX? – (5 min.) • Installation of software – (25 min.) • LaTeX (1): Syntax, sections, figures, formula and tables – (30 min.) • Short break – (15 min.) • Reportstructure 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.) • Practiceassignments for thoseinterested – (30-60 minutes) latex.mikkl.dk – latex@antistof.dk
What is LaTeX? • Documentswithout WYSIWYG (Whatyousee is whatyouget) • Pronounced ”Lah-tech” • Basedon the ”TeX” typesetlanguage from 1982 • Popular for technicalreports and books latex.mikkl.dk – latex@antistof.dk
Program • Intro – WhyuseLaTeX? – (5 min.) • Installation of software – (25 min.) • LaTeX (1): Syntax, sections, figures, formula and tables – (30 min.) • Short break – (15 min.) • Reportstructure 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.) • Practiceassignments for thoseinterested – (30-60 minutes) latex.mikkl.dk – latex@antistof.dk
Installation • LaTeX distribution • Windows: MiKTeX (Basic Installation) • Mac: MacTex • Text editor • Windows: TeXnicCenter • Mac: TeXShop • PDF viewer • PDF X-Changerecommended • Adobe/otherpdf-viewer is fine latex.mikkl.dk – latex@antistof.dk
Program • Intro – WhyuseLaTeX? – (5 min.) • Installation of software – (25 min.) • LaTeX (1): Syntax, sections, figures, formula and tables – (30 min.) • Short break – (15 min.) • Reportstructure 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.) • Practiceassignments for thoseinterested – (30-60 minutes) latex.mikkl.dk – latex@antistof.dk
LaTeXSyntax • LaTeX is written in ”.tex” files • ”\” (backslash) before a command • ”{}” (curlybraces) around the text the command is applied to. • E.g.:”\textit{Italic font}” = Italic font”\textbf{Bold font}” = Bold font • Some editors have buttonsthatwillinsertcommands for you. • ”%” (percent sign) beforecomments. Commentsdon’t show up in the compiled PDF. latex.mikkl.dk – latex@antistof.dk
A LaTeXdocumentconsists of: • Preamble – defines the style, whatpackages to beused (packagesareused for certaincommands and styles – more onthis in LaTeX part 2} • \begin{Document}Contentgoeshere!\end{document} latex.mikkl.dk – latex@antistof.dk
Sections • Numberedsections:\part{Part} (-1) I. Part \chapter{Chapter} (0) 1 Chapter\section{Section} (1) 1.1 Section\subsection{Subsection} (2) 1.1.1 Subsection • Non-numberedsections:\section*{Section}\subsection*{Subsection}Just add ”*” before{} latex.mikkl.dk – latex@antistof.dk
Figures • Basicfloat:\begin{figure}[htb] \includegraphics{images/chap1/image.jpg} \end{figure} • h – Heret – topb – bottomp – ”page of floats”H – HERE! Must placefigurehere! (usesparingly) latex.mikkl.dk – latex@antistof.dk
Figures • With more options:\begin{figure}[htb] \centering \includegraphics{images/chap1/image.jpg} \caption{This is mycaption} \end{figure} • Captioncanbeabove image as well • EasywithTeXnicCenter • Manyexamplesonlatex.mikkl.dk latex.mikkl.dk – latex@antistof.dk
Formula • ”Inlineformula” – togetherwith the text:dollar sign ($) before and afterformula.$2*\pi*r$ • Numbered/Non-numberedformula:\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 – latex@antistof.dk
Tables • One of the harderthings in LaTeX • Basictable:\begin{tabular}{ l | c || r | } 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\\end{tabular} • Column adjusting & - change columnl – left \\ - changerowc – center \hline – horizontal line betweenrowsr – right | - Vertical line between columns latex.mikkl.dk – latex@antistof.dk
Tables • Numberedtable:\begin{table} \centering\begin{tabular}{|l|c|c|c|}\hline& Firma 1 & Firma 2 & Firma 3 \\\hline Grundpris & 3000 & 2800 & 3100 \\\hline Liftkort & 1000 & 1100 & 1000 \\\hlineSkileje& 750 & 750 & 700 \\\hline Samlet & 4750 & 4650 & 4800 \\\hline\caption{Pris for skiferie}\end{table} latex.mikkl.dk – latex@antistof.dk
Program • Intro – WhyuseLaTeX? – (5 min.) • Installation of software – (25 min.) • LaTeX (1): Syntax, sections, figures, formula and tables – (30 min.) • Short break – (15 min.) • Reportstructure 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.) • Practiceassignments for thoseinterested – (30-60 minutes) latex.mikkl.dk – latex@antistof.dk
Program • Intro – WhyuseLaTeX? – (5 min.) • Installation of software – (25 min.) • LaTeX (1): Syntax, sections, figures, formula and tables – (30 min.) • Short break – (15 min.) • Reportstructure 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.) • Practiceassignments for thoseinterested – (30-60 minutes) latex.mikkl.dk – latex@antistof.dk
“Includes” • \include{path/to/file}insert all content of ”file.tex” (do not include ”.tex”) • Path is relative to root .tex file • E.g.: Ourroot file ”report.tex is in C:/reportMakeincludes 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 – latex@antistof.dk
Reportstructure latex.mikkl.dk – latex@antistof.dk
Reportstructure • Make up yourownstructure to fityourneeds and style • Rules of thumb: • Remember to make \includeswheneveryouadd a file to the report • Pathsare relative to the ROOT file (report.tex) • Avoid long file and pathnames • Avoidvery large .tex files (problematicwithseveralauthors) latex.mikkl.dk – latex@antistof.dk
Reporttemplate • http://latex.mikkl.dk/index.php?title=Fil:Rapportskabelon.zip • Containts the folder structurewe just discussed, alongwithpreamble, frontpage and a .tex file with a range of examples. • Let’s test if it compilescorrectly! latex.mikkl.dk – latex@antistof.dk
Program • Intro – WhyuseLaTeX? – (5 min.) • Installation of software – (25 min.) • LaTeX (1): Syntax, sections, figures, formula and tables – (30 min.) • Short break – (15 min.) • Reportstructure 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.) • Practiceassignments for thoseinterested – (30-60 minutes) latex.mikkl.dk – latex@antistof.dk
Version control • Referred to as ”SVN” or ”Subversion” • Awesometool for cooperativeauthoring • SVN terms: • ”Update” – Updatemylocalcopy so I have the newest version • ”Commit” – Create a new version withmychanges • ”History” – Lists versions (whochangedwhat file and when) • ”Merge” – If severalauthors have edited the same file • ”Conflict” – If severalauthors have edited the same lines of a file • ”Revert” – Rollback to a previous version (file or folder) latex.mikkl.dk – latex@antistof.dk
Version control • SVN explainedgraphically: http://aliensystems.ic.cz/svn.swf • Demo of Commit/UpdatewithTortoiseSVN • Handling an SVN conflict • SVN server? latex.mikkl.dk – latex@antistof.dk
Program • Intro – WhyuseLaTeX? – (5 min.) • Installation of software – (25 min.) • LaTeX (1): Syntax, sections, figures, formula and tables – (30 min.) • Short break – (15 min.) • Reportstructure 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.) • Practiceassignments for thoseinterested – (30-60 minutes) latex.mikkl.dk – latex@antistof.dk
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 – latex@antistof.dk
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 willbe: ”Figure 1 is a picture of a duck!” latex.mikkl.dk – latex@antistof.dk
Labels and Cross-references • Agreeon a namingscheme for your labels, e.g.:fig:label, tab:label, img:label, math:label, sec:label etc. • Labels arecase-sensitive - easier to use all lower case letters • Youcan NOT have 2 of the same labels • References to an unknown label willresult in ”??” • Files must becompiledseveral times – LaTeXcan’tknowabout all labels on the firstrun-through • See the latex.mikkl.dk page on ”TeXnicCenter” for setup of a buildprofilethatcompiles latex, bibtex, latex, latex. latex.mikkl.dk – latex@antistof.dk
Labels and Cross-references • Reference to section:\section{My Section}\label{sec:my_section}Hello!\section{AnotherSection}In section~\ref{sec:my_section} I said ”Hello!”. latex.mikkl.dk – latex@antistof.dk
Bibtex and Citations • Sourcesarestored in a ”.bib” file withentrieslike: @article{latexarticle1,author = ”Mikkel Madsen", title = ”The LaTeXCookbook", year = ”2010", pages = "342--351" } • Citing a source:\cite{latexarticle1}will output ”[X]” with x being the number of the source. • The bibliographywill list yoursources under theirownnumber, so readerscanconsult it for details latex.mikkl.dk – latex@antistof.dk
Bibtex and Citations • See the LaTeXwikibook for bibtexexampleshttp://en.wikibooks.org/wiki/LaTeX/Bibliography_Management • Inserting the bibliography (bib.bib): \bibliography{bib} • Changingstyle (put thisbefore \bibliography{}):\bibliographystyle{ieeetr}”ieeetr” numbers in order of appearance, for otherstylessee:http://www.cs.stir.ac.uk/~kjt/software/latex/showbst.html latex.mikkl.dk – latex@antistof.dk
The FiXmepackage • Add the package in Preamble:\usepackage[footnote,draft,english,silent,nomargin]{fixme} • Add a fixme for stuffthatneeds to betakencare of, orthatotherauthors must look at. • \fxnote{Note here} – inserts a footnotewithyour note • \listoffixmesgenerates 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 – latex@antistof.dk
Program • Intro – WhyuseLaTeX? – (5 min.) • Installation of software – (25 min.) • LaTeX (1): Syntax, sections, figures, formula and tables – (30 min.) • Short break – (15 min.) • Reportstructure 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.) • Practiceassignments for thoseinterested – (30-60 minutes) latex.mikkl.dk – latex@antistof.dk
Program • Intro – WhyuseLaTeX? – (5 min.) • Installation of software – (25 min.) • LaTeX (1): Syntax, sections, figures, formula and tables – (30 min.) • Short break – (15 min.) • Reportstructure 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.) • Practiceassignments for thoseinterested – (30-60 minutes) latex.mikkl.dk – latex@antistof.dk