Introduction To LATEX - Massachusetts Institute Of

Transcription

Introduction to LATEXIntroduction to LATEXWriting papers the right wayRSI 2015 StaffResearch Science InstituteMassachusetts Institute of Technology

Introduction to LATEXIntroductionTable of Contents1 Introduction2 A Basic Document3456Writing LaTeX CodeBasic FormattingLATEX and YouThe FilesMath ModeFigures and TablesBeamerLATEX ExtendedCommon ErrorsMore MathMacrosConclusion

Introduction to LATEXIntroductionLATEX is. . . . . a sophisticated document preparation sytem.LATEX has. . .Stylistic uniformityBibliography supportSophisticated structuring abilitiesReference trackingHighly extendible capabilities

Introduction to LATEXIntroductionLATEX is not. . . . . a word processor.LATEX does not. . .Spell-check your documents1Give you complete control over formattingProvide a graphical interface for editing“You take care of writing, and we’ll take care of presentation.”1You can use ispell to check your LATEX

Introduction to LATEXIntroductionWhy LATEX?Presentation shouldn’t get in the way of content.For example. . .With a word processor, you spend valuable time agonizing overwhat font size to make the section headings.With LATEX, you just tell it to start a new section.With a word processor, changing the formatting means you have tochange each instance individually.With LATEX, you just redefine the relevant commands.With a word processor, you have to carefully match any providedtemplates.With LATEX, you can be sure you’ve fit the template, and switchtemplates easily.

Introduction to LATEXA Basic DocumentTable of Contents1 Introduction2 A Basic Document3456Writing LaTeX CodeBasic FormattingLATEX and YouThe FilesMath ModeFigures and TablesBeamerLATEX ExtendedCommon ErrorsMore MathMacrosConclusion

Introduction to LATEXA Basic Document”Hello LATEX!”Creating a LATEX DocumentWrite a .tex file using any text editor and save it in theMiniPaper folder% this is llo, \LaTeX!\end{document}Compile using the RSI Makefile cd /RSI/MiniPaper/ make hello.pdfPreview the results evince hello.pdf &

Introduction to LATEXA Basic DocumentWriting LaTeX CodedocumentclassLATEX has several templates, selected using rEtc.You’ll be using the ‘article’ class for your paper, ‘beamer’ class foryour presentation

Introduction to LATEXA Basic DocumentWriting LaTeX CodeDeclarations and EnvironmentsDeclarations. . .Are stated onceTake effect until further noticeCan optionally be constrainedEx. \documentclass, \smallEnvironments. . .Have matching begin and end declarationsMust be constrainedEx. \begin{document} .\end{document}

Introduction to LATEXA Basic DocumentWriting LaTeX CodeArgumentsRequired arguments. . .Are contained in curly bracesMust be includedEx. \documentclass{article}Optional arguments. . .Are contained in square bracketsCan be left outGive you more control over the commandsEx. \documentclass[12pt]{article}

Introduction to LATEXA Basic DocumentWriting LaTeX CodeSpecial CharactersAnother type of commandDon’t define any formatting or structurePrint non-standard characters or characters which usuallymean something elseEx. \LaTeX, \textbackslash, \%Note: % is a special character reserved for comments (after a %,the rest of a line is ignored by the compiler)

Introduction to LATEXA Basic DocumentWriting LaTeX CodePackagesPackages allow you to further customize LATEX.The command:\usepackage{name}Some packages:graphicx, epsfig, geometry, fancyhdr, setspace, amsmath, listings,xcolor, url. . .Most of the packages you’ll need are already included in thetemplate

Introduction to LATEXA Basic DocumentBasic FormattingFont TypesFont face:\emph{Text}, \textbf{Text}, \texttt{Text}, \textrm{Text},\textsf{Text}, \textsc{Text}Font size:{\tiny Text}, {\scriptsize Text}, {\footnotesize Text},{\small Text}, {\normalsize Text}, {\large Text}, {\LargeText}, {\LARGE Text}, {\huge Text}, }.\end{center/flushright/flushleft}Text}

Introduction to LATEXA Basic DocumentBasic FormattingSpacingMarginsThe default: between 1.5 inches and 1.875 inchesSetting margins: \usepackage[margin 0.5in]{geometry}Paragraphs and other breaksParagraphs are separated by a blank line.You can force a new line using \\To force a new page, use \newpage or \clearpageOther spacingForce a space using Add space using \hspace{1in} or \vspace{1in}Fill space using \hfill or \vfill

Introduction to LATEXA Basic DocumentBasic FormattingListsThere are two main types. . .Bulleted lists:\begin{itemize}\item Text\item Text\end{itemize}TextTextNumbered lists:\begin{enumerate}\item Text\item Text\end{enumerate}1Text2Text

Introduction to LATEXLATEX and YouTable of Contents1 Introduction2 A Basic Document3456Writing LaTeX CodeBasic FormattingLATEX and YouThe FilesMath ModeFigures and TablesBeamerLATEX ExtendedCommon ErrorsMore MathMacrosConclusion

Introduction to LATEXLATEX and YouThe FilesThe RSI File StructureIn your MiniPaper or Paper directory, you’ll notice several files. . .main.tex brings everything together, don’t edit itpreamble.tex contains any additional packages or macroscover.tex contains the cover information (title, author, etc.)abstract.tex and summary.tex contain the text of yourscientific abstract and executive summary, respectivelypaper.tex contains the main body of your paper, includingany and all figures, tables, etc.biblio.bib is a BibTEX file containing your referencesappa.tex contains the text of any appendices you may haveCompile using make main.pdf

Introduction to LATEXLATEX and YouThe FilesThe Title Pagecover.tex is where you define the content of your title pageIt includes declarations of the title, author, and dateYou should replace the title and author as needed, but leavethe date alone\title{Length-enhanced superlative verbiage}\author{Joe Everystudent\vspace{0.5in}\\under the direction of\\Dr. Famous Person\\Massachusetts Institute of Technology\vspace{1in}}The title page is created automatically using the maketitlecommand in main.tex

Introduction to LATEXLATEX and YouThe FilesAbstract and SummaryThe minipaper only has an abstractYour final paper will have both a technical abstract and anon-technical summaryAll you need to do is fill in the text, and the template takescare of the restBehind the ummary}\end{abstract}

Introduction to LATEXLATEX and YouThe FilesBibliographybiblio.bib acts as a database of references, and only includes inthe bibliography those references you cite in your paperBibTEX@article{nameofentry,author {John Backus},title {Symmetric Encryption},journal {Journal of Modalities},volume 46,year 1993,number 2,pages {44--57}}A more complete list of examples can be found atweb.mit.edu/rsi/www/pdfs/bibtex-format.pdf

Introduction to LATEXLATEX and YouThe FilesThe PaperLATEX is built off of the idea of structure over formatting\section{Introduction}Layers of ubparagraphThese commands should be used as needed in both paper.texand appa.tex

Introduction to LATEXLATEX and YouThe res}.As seen in Section \ref{res} .Footnotes.telephony\footnote{Phony telephones}CitationsRedundancy \cite{nameofentry}For multiple citations:.methodology \cite{nameofentry, nameofotherentry}

Introduction to LATEXLATEX and YouMath ModeTypesetting MathLATEX allows you to typeset any sort of equations.LATEX math supportZabdθ tan 1 b tan 1 a1 θ2Using math modeInline math mode: . R 1e x dxP n 0 n!Display math mode: . Numbered equations: \begin{equation}.\end{equation}

Introduction to LATEXLATEX and YouMath ModeSome Commands9744 2 35PnxyAxyk 1 k2 6 4φ Ψı̂ ̂ k̂f 00 (ξ)CH3 COOH180 C 974 4 2 \sqrt[3]{5} \frac{x}{y} A {x} {y} \sum {k 1} n k 2 \ne 4 \phi \in \Psi \hat{\i} \times \hat{\j} \hat{k} f’’(\xi) CH 3 COOH180 {\circ} C.runs in \Theta(\log n) time.

Introduction to LATEXLATEX and YouMath ModeMath symbols resourcesDetexify: http://detexify.kirelabs.orgDraw a symbol, Detexify tells you a bunch of possibleLATEXsymbolsAoPS symbols: LaTeX:SymbolsAlso has lots of other LATEXresourcesRSI Website (go to “Tech help”)

Introduction to LATEXLATEX and YouMath ModeMath exercisesWrite the follow basic equations in LATEX.3 1 2 2nX i2 n(n 1)2xi 1 b b 2 4ac2a

Introduction to LATEXLATEX and YouMath ModeMore math exercisesHere are some trickier equations (not just math) to try:IdΦEB · dS µ0 0 µ0 iencdtk Ae EA /RT[H3 0 ][A ]Ka [HA] MV V (λ) V non-spλ Spec(T )

Introduction to LATEXLATEX and YouFigures and TablesFigures and TablesBoth are les\begin{table}.\end{table}Positioning can be defined as an optional argument:\begin{figure}[htbp]

Introduction to LATEXLATEX and YouFigures and TablesincludegraphicsThe Commands\subsection{Hardware graphics[height ntering\includegraphics[width \textwidth]{figure1.png}\end{figure}

Introduction to LATEXLATEX and YouFigures and TablesFormatting TablesThe table environment defines the figure style. The tabularenvironment defines the table itself.\section{Related Work}\begin{table}[ht]\centering\begin{tabular}{ r c c } \hlineTrial & n & t \\ \hline1 & 23 & 2 \\ \hline2 & 15 & 10 \\ \hline3 & 100 & 20 \\ 20

Introduction to LATEXLATEX and YouFigures and TablesCaptions and LabelsCaptioning\end{tabular}\caption{The data.}\end{table}Labeling\caption{The data.}\label{nameoftable}\end{table}Referencing.in Table \ref{nameoftable}

Introduction to LATEXBeamerTable of Contents1 Introduction2 A Basic Document3456Writing LaTeX CodeBasic FormattingLATEX and YouThe FilesMath ModeFigures and TablesBeamerLATEX ExtendedCommon ErrorsMore MathMacrosConclusion

Introduction to LATEXBeamerGetting StartedBeamer allows all the same commands as a normalLATEX document, plus some.Adding a Slide\begin{frame}{Title}.\end{frame}Special slidesTitle slide:\titlepageTable of contents:\tableofcontents[currentsection]

Introduction to LATEXBeamerBeamer at RSIWe have a template for this too! It’s in the file slides.texTitle SlideBe sure to fill in the title, subtitle (if necessary) and author\title{Witty catch-phrase}\subtitle{Length-enhanced superlative verbiage}\author[Joe Everystudent]{Joe Everystudent\\Research Science Institute\\Under the Direction of Dr. Famous Person\\Massachusetts Institute of Technology}The template already includes a title slide!

Introduction to LATEXBeamerFormattingSome special environments can be useful for s\begin{columns}\column{0.5\textwidth}Column 1\column{0.5\textwidth}Column 2\end{columns}

Introduction to LATEXBeamerAnimationYou can also do some basic animation in beamer.

Introduction to LATEXBeamerAnimationYou can also do some basic animation in beamer.\pause puts a pause before revealing the rest of the slide

Introduction to LATEXBeamerAnimationYou can also do some basic animation in beamer.\pause puts a pause before revealing the rest of the slidecommand num-num makes the command apply only forsome number of the “frames”

Introduction to LATEXBeamerAnimationYou can also do some basic animation in beamer.\pause puts a pause before revealing the rest of the slidecommand num-num makes the command apply only forsome number of the “frames”The previous bullet is defined by \item 3-4

Introduction to LATEXBeamerAnimationYou can also do some basic animation in beamer.\pause puts a pause before revealing the rest of the slideThe previous bullet is defined by \item 3-4 The bullet disappears after the fourth “frame”

Introduction to LATEXBeamerThemesYou can also choose different themes for beamer.Design\usetheme{theme}Antibes, Berkeley, Berlin, Goettingen, Malmoe, Szeged, Warsaw. . .Color\usecolortheme{theme}beaver, crane, lily, rose, seahorse, whale. . .

Introduction to LATEXLATEX ExtendedTable of Contents1 Introduction2 A Basic Document3456Writing LaTeX CodeBasic FormattingLATEX and YouThe FilesMath ModeFigures and TablesBeamerLATEX ExtendedCommon ErrorsMore MathMacrosConclusion

Introduction to LATEXLATEX ExtendedCommon ErrorsThe Structure of an Error

Introduction to LATEXLATEX ExtendedCommon ErrorsMissing Closing BracesThe Code\includegraphics{picture.pngThe Error Message

Introduction to LATEXLATEX ExtendedCommon ErrorsMissing Environment EndThe Code\begin{itemize}\item Text.The Error Message

Introduction to LATEXLATEX ExtendedCommon ErrorsSpaces in FilenamesThe Code\includegraphics{a picture.png}The Error Message

Introduction to LATEXLATEX ExtendedCommon ErrorsForgetting to EscapeThe CodeabThe Error Message

Introduction to LATEXLATEX ExtendedCommon ErrorsForgetting to Use Math ModeThe Code\frac{1}{2}The Error Message

Introduction to LATEXLATEX ExtendedMore MathDefining Theorems and MoreThe Code% This is preamble.tex\newtheorem{name}{Display Name}Example% This is preamble.tex\newtheorem{thm}{Theorem}Example, continued% This is paper.tex\begin{thm}Herding cats is hard.\end{thm}

Introduction to LATEXLATEX ExtendedMore MathMore on TheoremsAdding a Reference\begin{thm}[Cain, 2002]Herding Rickoids is harder.\end{thm}Proving your Theorems% This is paper.tex\begin{proof}.\end{proof}

Introduction to LATEXLATEX ExtendedMacrosWhat are Macros?LATEX allows you to define or redefine commands as you pleaseIn fact, LATEX itself is a set of macros on top of TEX\newcommand{name}[num]{definition}

Introduction to LATEXLATEX ExtendedMacrosResetting CommandsChanging arindent}{1cm}\setlength{\parskip}{1cm plus4mm minus3mm}Changing titlesEx.\renewcommand{\abstractname}{Summary}

Introduction to LATEXConclusionTable of Contents1 Introduction2 A Basic Document3456Writing LaTeX CodeBasic FormattingLATEX and YouThe FilesMath ModeFigures and TablesBeamerLATEX ExtendedCommon ErrorsMore MathMacrosConclusion

Introduction to LATEXConclusionSo, why LATEX?LATEX allows you to worry about the content and thestructure, rather than the presentation.LATEX has one of the most advanced math typesetting systemsaround.LATEX is incredibly extendible.LATEX keeps track of references so you don’t have to.LATEX allows you to make more consistent, and more easilychangeable, documents.

Introduction to LATEXConclusionGetting Help and Learning MoreLATEX Wikibooks:en.wikibooks.org/wiki/LaTeXThe Not So Short Introduction to LATEX 2ε rt.pdfA Short Math Guide for math-guide.pdfThe Beamer Theme Matrix:www.hartwork.org/beamer-theme-matrix/Google is still your best friend!

Introduction to LATEX Introduction to LATEX Writing papers the right way RSI 2015 Sta Research Science Institute Massachusetts Institute of Technology. Introduction to LATEX Introduction Table of Contents 1 Introduction 2 A Basic Document Writing LaTeX Code Basic Formatting 3 LATEX and You . cover.tex c