2015.04.12 latex tutorial

Upload: apollo-silva

Post on 08-Jan-2016

235 views

Category:

Documents


0 download

DESCRIPTION

latex

TRANSCRIPT

  • GSC LaTeX TutorialDingyi Sun

    [email protected] Student

    Mechanical Engineering

    April 25, 2015 GSC LaTeX Tutorial 1

  • Objectives

    Assumption: no previous experience Develop basic skills for use

    Course assignments Notes Thesis Publications

    Supplementation

    April 25, 2015 GSC LaTeX Tutorial 2

  • General Flow

    April 25, 2015 GSC LaTeX Tutorial 3

    Text Editor(where your code goes)

    Implementation(compiles your code)

    Packages(to perform special functions)

    PresenterPresentation Notes- Text editor optional (can do it all in implementation)but can be faster

  • Compiling to PDF

    Usual desired outcome Can be done in text editor Command line: pdflatex

    Example

    April 25, 2015 GSC LaTeX Tutorial 4

  • Outline

    Document Basics Equations Tables Figures Additional customization References (BibTeX) Additional Packages Macros

    April 25, 2015 GSC LaTeX Tutorial 5

  • Document Basics

    April 25, 2015 GSC LaTeX Tutorial 6

  • General Document Structure

    1. Document class declaration2. Preamble: packages, macros, additional declarations3. Document: text, equations, tables, figures4. References: BibTeX, etc.5. Backmatter: appendices, index

    Example

    April 25, 2015 GSC LaTeX Tutorial 7

    PresenterPresentation Notes- Declarations global, but can be constrained by curly braces

  • Common Document Classes

    article: Most common for general use book report letter thesis beamer*

    April 25, 2015 GSC LaTeX Tutorial 8

    PresenterPresentation Notes- * = Use with caution

  • Sectioning

    \part{} \chapter{}: Not available in article \section{} \subsection{} \subsubsection{} \paragraph{} \subparagraph{} Stop numbering with * before {

    April 25, 2015 GSC LaTeX Tutorial 9

  • General Things in Text

    Standard text formatting present Boldfacing:

    Italicizing:

    Underlining:

    acts as expected inverts italicizing \hspace and \vspace insert spaces

    April 25, 2015 GSC LaTeX Tutorial 10

    \footnote{}

    \underline{}\textit{}\textbf{}

    \emph {}

  • Additional Text Formatting

    Sizes: \tiny \scriptsize, \footnotesize, \small \normalsize \large \Large \LARGE \huge \Huge

    April 25, 2015 GSC LaTeX Tutorial 11

    Additional Font Modifications: \textrm{}: Forces upright Roman \textsf{}: Switches to Serif \texttt{}: Typewriter \textsc{}: Small caps

    Alignment: flushleft flushright center

  • Lists

    April 25, 2015 GSC LaTeX Tutorial 12

    Bullet point list: Numbered list:

    \begin{enumerate}\item

    \end{enumerate}

    \begin{itemize}\item

    \end{itemize}

    Example

  • Labels and Referencing

    Highly-useful feature Establish reference: Call reference: Good for anything (equations, figures, tables, theorems, etc.)

    Example

    April 25, 2015 GSC LaTeX Tutorial 13

    \label{}\ref{}

  • Equations

    April 25, 2015 GSC LaTeX Tutorial 14

  • Inline Equations

    Compact Supplementary/supporting formulas Non-display style

    \displaystyle{} to toggle Avoid squished formulas

    April 25, 2015 GSC LaTeX Tutorial 15

    $ $

  • Non-Numbered Line Equations

    Sub-critical equations Display style Multiple lines per environment*

    gathered: Standard, multi-line aligned: Use & as alignment delimeter \hfill to fill in blank line spaces \\ as line breaker

    April 25, 2015 GSC LaTeX Tutorial 16

    \[ \]

    PresenterPresentation Notes- * = Multi-line after ams included

  • Numbered Equations

    Points of focus Display style Same multi-line properties as before Best used with labels

    April 25, 2015 GSC LaTeX Tutorial 17

    \begin{equation}

    \end{equation}

  • Example and Exercise

    Example

    Exercise: Reconstruct the document Start with blank file Cumulative Call for help if needed Sample solution

    April 25, 2015 GSC LaTeX Tutorial 18

    PresenterPresentation Notes- Change up the examples?

  • Formatted Text in Math Environments

    Standard text formatting still present Boldfacing:

    Italicizing:

    Underlining:

    Shortcomings with extended alphabets

    April 25, 2015 GSC LaTeX Tutorial 19

    \underline{}\mathit{}\mathbf{}

  • ams Series Packages

    Packages: amsmath: Symbols, operators, improved functionality amsfonts: Expanded font families amsthm: Help define theorem environments amssymb: More symbols

    Generally good to have Vast expansion of mathematics

    April 25, 2015 GSC LaTeX Tutorial 20

  • Subequations

    Can insert text between equations

    April 25, 2015 GSC LaTeX Tutorial 21

    \begin{subequations}\begin{gather}

    \end{gather}\end{subequations}

    \intertext{}

  • Recap

    Load ams packages!

    ExampleExercise

    Sample solution

    April 25, 2015 GSC LaTeX Tutorial 22

  • Tables

    April 25, 2015 GSC LaTeX Tutorial 23

  • The Standard tabular Environment

    # alignment specifiers = # columns Problems if # specifiers < # columns

    & to denote new column \\ to denote line break Blank columns okay \hline for spanning horizontal line

    April 25, 2015 GSC LaTeX Tutorial 24

    \begin{tabular}{}

    \end{tabular}

  • The Standard tabular Environment

    Important alignment specifiers: Can wrap in table environment

    Captions and labeling easier

    Example

    April 25, 2015 GSC LaTeX Tutorial 25

    \begin{tabular}{}

    \end{tabular}

    Alignment Effectl Left-justified columnc Centered columnr Right-justified column| Single vertical line (separating columns)|| Double vertical line (separating columns)

  • Figures

    April 25, 2015 GSC LaTeX Tutorial 26

  • Inserting Graphics

    April 25, 2015 GSC LaTeX Tutorial 27

    \begin{figure}[]\begin{}

    \includegraphics[]{}\end{}\caption{}\label{}\end{figure}

    Need the graphicx package Should probably load in

    general Specify alignment options Captioning and label like in

    table minipage for placement?

  • Float Locations

    Optimal placement Forced placement with other packages (float) Weighted placements:

    April 25, 2015 GSC LaTeX Tutorial 28

    \begin{figure}[]

    Option Effecth Approximately heret Top of the pageb Bottom of the pagep On a floats-only page! Additional weight on placement

  • Subfigures

    Load subcaption Allows for figures in figures

    Example

    April 25, 2015 GSC LaTeX Tutorial 29

    \begin{figure}\begin{subfigure}[]{}

    \includegraphics{}\caption{}\label{}

    \end{subfigure}\caption{}\label{}

    \end{figure}

  • Halftime Exercise

    Toy example with nonlinear fit Figures included in directory Covers everything up to now

    Exercise Sample solution

    April 25, 2015 GSC LaTeX Tutorial 30

  • Additional Document Customization

    April 25, 2015 GSC LaTeX Tutorial 31

  • Document-Wide Customization

    Specify at class declaration Number of columns Font size

    Specify at preamble Font modification packages Font family defaults: \rmdefault, \sfdefault, \ttdefault \renewcommand{}

    Example

    April 25, 2015 GSC LaTeX Tutorial 32

  • Multicolumn Sections

    Needs the package multicol

    Limited section of multicolumn text Divides lists automatically Figure space reduction

    Example

    April 25, 2015 GSC LaTeX Tutorial 33

    \begin{multicols}{}

    \end{multicols}

    PresenterPresentation Notes- Can use this to get around minipages if youd like

  • References

    April 25, 2015 GSC LaTeX Tutorial 34

  • Manual Bibliographies

    Cumbersome and repetitive Okay for rare citations Use \cite{}

    Example

    April 25, 2015 GSC LaTeX Tutorial 35

    \begin{thebibliography}{}\bibitem{}

    \end{thebibliography}

  • BibTeX

    Build up citation database Automatic sorting and formatting Slower to set up Many different classes

    Required & optional fields Easiest to look up

    Example (with .bib file)

    April 25, 2015 GSC LaTeX Tutorial 36

  • Some Additional Packages

    April 25, 2015 GSC LaTeX Tutorial 37

  • Interactive PDFs

    hyperref adds hyperlinks to references Can move around document Useful for interactive documents

    cleveref adds shortcut references hyperref before cleveref (if together) bookmark adds to PDFs

    Example

    April 25, 2015 GSC LaTeX Tutorial 38

  • Other Cool Packages color/xcolor: More color in documents geometry: Additional page customization fancyhdr: More customization of header imakeidx: Index entries for keywords listings: Useful for blocks of code longtable: Multi-page tables mathtools: Additional tools for mathematics mdframed: Framed environments physics: Built-in macros for physical sciences tabularx & tabulary: Additional column width specifications tocloft: Control of table of contents (book documents) wrapfig: Text wrapping around figures

    April 25, 2015 GSC LaTeX Tutorial 39

    List is not meant to be complete at all.Explore packages as you need them!

  • Custom Macros and Miscellaneous

    April 25, 2015 GSC LaTeX Tutorial 40

  • Macros

    For repetitive, complicated tasks Faster document writing Can build on loaded packages Avoid for publications!

    Example

    April 25, 2015 GSC LaTeX Tutorial 41

  • Final Exercise

    Hamiltonian systems Adopted & truncated from a problem set Use physics macros Some quick BibTeX entries

    Exercise Sample solution (with .bib file)

    April 25, 2015 GSC LaTeX Tutorial 42

  • Useful Links

    LaTeX cheat sheet A detailed introduction to LaTeX Wikibooks StackExchange

    April 25, 2015 GSC LaTeX Tutorial 43

  • Thanks for attending the session!Further questions? Email [email protected]

    April 25, 2015 GSC LaTeX Tutorial 44

    GSC LaTeX TutorialObjectivesGeneral FlowCompiling to PDF OutlineDocument BasicsGeneral Document StructureCommon Document ClassesSectioningGeneral Things in TextAdditional Text FormattingListsLabels and ReferencingEquationsInline EquationsNon-Numbered Line EquationsNumbered EquationsExample and ExerciseFormatted Text in Math Environmentsams Series PackagesSubequationsRecapTablesThe Standard tabular EnvironmentThe Standard tabular EnvironmentFiguresInserting GraphicsFloat LocationsSubfiguresHalftime ExerciseAdditional Document CustomizationDocument-Wide CustomizationMulticolumn SectionsReferencesManual BibliographiesBibTeXSome Additional PackagesInteractive PDFsOther Cool PackagesCustom Macros and MiscellaneousMacrosFinal ExerciseUseful LinksThanks for attending the session!