ltex and beamer: open source alternatives to microsoft o ce...

34
L A T E X and Beamer: Open Source Alternatives to Microsoft Oce For Documents and Presentations —or— Why Keep Payin’ ’da Man When You Can Do Better? Mark R. Galvin K Nelson Department of Nuclear Engineering and Radiation Health Physics Oregon State University 13 November 2008 Mark R. Galvin/K Nelson L A T E X and Beamer

Upload: others

Post on 22-Apr-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

  • LATEX and Beamer: Open Source Alternatives toMicrosoft Office For Documents and Presentations

    —or—Why Keep Payin’ ’da Man When You Can Do Better?

    Mark R. GalvinK Nelson

    Department of Nuclear Engineering and Radiation Health PhysicsOregon State University

    13 November 2008

    Mark R. Galvin/K Nelson LATEX and Beamer

  • What’s This All About?

    Objective is to answer the following questions:

    What is Free/Open Source Software?What the heck are TEX and LATEX?Who uses LATEX?Why would I use LATEX?Why wouldn’t I use LATEX?How do I get LATEX?How do I use LATEX?

    A Note on Beamer:Beamer is one of several available presentation makingpackages that use the LATEX markup format and the TEX engineto produce beautiful presentations (like this one) in PDF format.Beamer won’t explicitly be discussed.

    Mark R. Galvin/K Nelson LATEX and Beamer

  • Free/Open Source Software. . . think free speech, not free beer

    What is F/OSS?Free/open source software (F/OSS) is software for which thehuman-readable source code is made available to the user ofthe software, who can then modify the code in order to fit thesoftware to the user’s needs. The source code is the set ofwritten instructions that define a program in its original form,and when it’s made fully accessible programmers can read it,modify it, and redistribute it, thereby improving and adapting thesoftware. In this manner the software evolves at a rateunmatched by traditional proprietary software.

    Where is it?Hiding on the internet. If Google doesn’t find it, try the FreeSoftware Foundation, SourceForge.net, University Media Labs,Government Laboratories, User Groups, etc.

    Mark R. Galvin/K Nelson LATEX and Beamer

  • Why Use F/OSS?

    You can usually get a commercial product for your needWay more features than you needFreeware and shareware usually come with baggageYou can’t afford custom software

    but with F/OSS . . .An equivalent to most every major software packageexists, pre-compiled and ready to useNo proprietary issues, high degree of compatibility amongF/OSS packagesMost “established” packages have user groups willing tohelp you understand how to use or modify the softwareIt’s always free, and usually doesn’t cost anything either

    Mark R. Galvin/K Nelson LATEX and Beamer

  • The Drawbacks

    F/OSS is great, but sometimes it isn’t that greatUsually less polished than commercial softwareEvery user is expected to be a beta testerMay not (yet) be optimized for speedSometimes limited (or no) documentationFew F/OSS packages are standardsCompatibility with commercial software may lag one ormore generations behind

    Remember, this software is mostly written by computer nerds intheir free time. Your expectations should be proportional to theprice you paid. In many ways, getting F/OSS is like dumpsterdiving for furniture. You might need to clean it up, but once youdo everyone thinks you inherited a family heirloom.

    Mark R. Galvin/K Nelson LATEX and Beamer

  • F/OSS Essentials I

    Some Commercial Equivalents:

    Commercial F/OSS WebsiteMicrosoft Office Open Office www.openoffice.orgMicrosoft Internet Explorer Mozilla Firefox www.getfirefox.comMicrosoft Outlook Mozilla Thunderbird www.mozilla.org/thunderbirdMicrosoft Word Abiword www.abisource.comNorton Antivirus ClamWin www.clamwin.comAdobe Photoshop GIMPShop www.gimpshop.netWindows Media Player VLC Player www.videolan.org/vlcWinFTP Filezilla filezilla.sourceforge.netAdobe Acrobat PDFCreator OSUWare CDGoogle Earth NASA Worldwind worldwind.arc.nasa.govMathmatica Maxima maxima.sourceforge.netMATLAB Octave www.gnu.org/software/octave

    Mark R. Galvin/K Nelson LATEX and Beamer

    www.openoffice.orgwww.getfirefox.comwww.mozilla.org/thunderbirdwww.abisource.comwww.clamwin.comwww.gimpshop.netwww.videolan.org/vlcfilezilla.sourceforge.networldwind.arc.nasa.govmaxima.sourceforge.netwww.gnu.org/software/octave

  • F/OSS Essentials II

    Other Good Stuff I Like:

    Package Description WebsiteMiKTeX Windows LATEX implementation www.miktex.orgRedHat Linux operating system www.redhat.comPovRay Ray-tracing program www.povray.orgTrueCrypt Encrypt memory stick www.truecrypt.orgHandbrake Copy DVD to your hard drive handbrake.m0k.orgJabRef Bibliography reference manager jabref.sourceforge.netTrue Combat: Elite Multiplayer combat/action www.truecombatelite.net

    Mark R. Galvin/K Nelson LATEX and Beamer

    www.miktex.orgwww.redhat.comwww.povray.orgwww.truecrypt.orghandbrake.m0k.orgjabref.sourceforge.netwww.truecombatelite.net

  • The TEX Document Typesetting System

    TEX was created by Donald Knuth (and others) to typesetcomputer programming manuscripts

    Catalyst was obsolescence of hot press typesettingFirst release took over ten years to completeIncluded METAFONT font description system which allows the designer todescribe characters algorithmicallyTEX markup language is primitive by today’s standards, but was veryadvanced when first releasedCopyright vested with American Mathematical Society

    Availability of source code led to other TEX dialectsStill others created markup formats (i.e., have collectionsof macros written in one of the TEX dialects) to simplifywriting a TEX-based document

    LATEX is most common plain TEX markup format, but many others based onthe other TEX dialects existWhat you use is generally what you start with

    “We live in Iowa, son, that makes us corn people!”

    Mark R. Galvin/K Nelson LATEX and Beamer

  • The “Levels” of a TEX System

    EnginesTEX, pdfTEX, XeTEX, LuaTEX, etc. These are the actual executable binarieswhich implement the different TEX dialects.

    FormatsLATEX, plain TEX, etc. These are the TEX-based languages in which youactually write documents.

    Packagesgeometry, lm, amsmath, etc. These are add-ons to the basic TEX system,developed independently, providing additional typesetting features, fonts,documentation, etc. The CTAN web sites provide access to the vastmajority of packages in the TEX world.

    Front endsEmacs, TEXShop, TEXnicCenter, WinEdt, LEd, etc. These editors are whatyou use to create a document file. TEX documents are independent of anyparticular editor; the actual TEX typesetting program itself does not carehow you created your file. This is in stark contrast to programs such asMicrosoft Word, where editing and typesetting are fundamentallyintertwined.

    DistributionsMiKTEX, TEX Live, etc. These are the large collections of TEX-relatedsoftware to be downloaded and installed.

    Mark R. Galvin/K Nelson LATEX and Beamer

  • What is Good About LATEX?Break free of the Gates’ Jedi mind trick. . .

    Superior typographic qualityOutput is, typographically, far better than any of the alternatives

    Output device independenceFormatting applied does not depend on the printer designated as “current”

    PortabilityRuns on virtually any operating system; output formats are not proprietary

    Document longevityNo planned obsolescence here. . .

    Macros and other programmatic featuresLATEX lets the user define macros that can be used repeatedly

    Mathematical typesettingThere’s a reason Word has a LATEX-based equation editor add-in

    Technical support from the package author (usually)There are a large number of TEX and LATEX users groups Most packagewriters provide contact information (and actually answer email, even ifhalf-a-world away)

    Mark R. Galvin/K Nelson LATEX and Beamer

  • Some ExamplesPhotoelectric Effect (Author: Poul Riis, created using Tikz)

    ++++

    Incoming γ-photon

    Photoelectron from aninner shell

    Mark R. Galvin/K Nelson LATEX and Beamer

  • Some ExamplesCompton Scattering (Author: Poul Riis, created using Tikz)

    ++++

    Incoming γ-photon Scattered electron froman outer shell

    Scattered γ-photon

    Mark R. Galvin/K Nelson LATEX and Beamer

  • Some ExamplesPair Production (Author: Poul Riis, created using Tikz)

    ++++

    Incoming γ-photon Positron

    Electron

    Mark R. Galvin/K Nelson LATEX and Beamer

  • Some ExamplesPressurized Water Reactor (Author: Gloria Faccanoni, created using Tikz)

    Containmentstructure

    Pressurized water(primary loop)

    Water and steam(secondary loop)

    Water(cooling loop)

    Liquid

    Steam

    Pump

    Steam generator(heat change)

    Turbine

    Generator

    Coolingtower

    Coolingwater

    Condenser Pump

    Pump

    Reactorcore

    Reactorvessel

    Controlrods

    Pressurizer

    Water coolant(330 ◦C)

    Water coolant(280 ◦C)

    Watervapor

    1

    Mark R. Galvin/K Nelson LATEX and Beamer

  • Some ExamplesNerdy Time Plot of Neutronics Project Data

    Mark R. Galvin/K Nelson LATEX and Beamer

    Linear.mp4Media File (video/mp4)

  • Some ExamplesA Sexy Piece of a Neutronics Project Writeup

    The updated effective multiplication factor, kℓ+1, is defined as:

    kℓ+1 = kℓL∫

    0

    dx[ν1Σ f ,1(x)φ̃ℓ+11 (x) + ν2Σ f ,2(x)φ̃

    ℓ+12 (x)

    ]

    where φ̃ℓ+1g (x) is the flux in group g that was determined through the polynomial expansion given byEquation (4), for the current iteration, and kℓ is the multiplication factor determined during the previousiteration. When the above equation is integrated, it is integrated on the interval [0,L/2] for node 1 then again onthe interval [L/2,L] for node 2 as

    kℓ+1 = kℓ

    L/2∫

    0

    dx[ν1Σ f ,1(x)φ̃ℓ+11 (x) + ν2Σ f ,2(x)φ̃

    ℓ+12 (x)

    ]Node 1

    +

    L∫

    L/2

    dx[ν1Σ f ,1(x)φ̃ℓ+11 (x) + ν2Σ f ,2(x)φ̃

    ℓ+12 (x)

    ]Node 2

    = kℓ

    L/2∫

    0

    dx[ν1Σ f ,1(x)φ̃ℓ+11 (x)

    ]Node 1

    + k

    L/2∫

    0

    dx[ν2Σ f ,2(x)φ̃ℓ+12 (x)

    ]Node 1

    +kℓ

    L∫

    L/2

    dx[ν1Σ f ,1(x)φ̃ℓ+11 (x)

    ]Node 2

    + kℓ

    L∫

    L/2

    dx[ν2Σ f ,2(x)φ̃ℓ+12 (x)

    ]Node 2

    Mark R. Galvin/K Nelson LATEX and Beamer

  • What is Bad About LATEX?Some find it a turn-off, others a challenge. . .

    More moving partsUsing LATEX means using an editor, LATEX itself, a document previewer(such as Adobe Reader), and usually a few other assorted programs;WYSIWYG word processors are self-contained

    Difficulty knowing/remembering markup commandsLearning the markup commands takes time, and can be frustrating

    Previewing delayThere is a delay between typing something in the editor and seeing theresult in the document previewer

    Possibility of syntax errorsUnlike in a WYSIWYG word processor, it is possible to create a tex file thatLATEX will reject, cryptically complaining of a syntax error

    Adding new fontsYou can’t just download some ttf (TrueType Font) file off the web and startusing it (but then again, most fonts aren’t worth using anyway)

    Lack of support for some document formatsIf someone hasn’t written a package for it, LATEX doesn’t support it

    Mark R. Galvin/K Nelson LATEX and Beamer

  • Other Essential TEX Tools

    MakeIndexUsed for producing a sorted index from unsorted raw data. Also processesglossaries, acronyms, and other lists of “location-defined” entries.(Standard in every TEX distribution.)

    BiBTEX:Tool for formatting lists of references. Most popular citation styles aresupported. (Standard in every TEX distribution.)

    JabRefReference management software that uses BibTEX as its native format.JabRef provides an easy-to-use graphical interface for editing BiBTEX files,for importing data from online scientific databases, and for managing andsearching BiBTEX files.

    BeamerHighly customizable presentation package for LATEX. Capable of producingeither a document (article, report, etc.) or a presentation from the samecontent, depending on how you process the content through the TEXengine. (Standard in every TEX distribution.)

    Excel2LATEXExcel add-in that formats spreadsheet data as a LATEX table.

    TthTEX to HTML converter. Very useful if you want to put a paper on-line withminimal processing.

    Mark R. Galvin/K Nelson LATEX and Beamer

  • Essential LATEX Packages

    graphicxEnhanced support for graphics

    xcolorDriver-independent color extensions for LATEX and pdfLATEX

    overpicCombine LATEX commands over included graphics

    geometryFlexible and complete interface to document dimensions

    movie15Multimedia inclusion package.

    amsmathAMS mathematical facilities and features for LATEX

    colortblAdd color to LATEX tables

    fancyhdrExtensive control of page headers and footers

    rotatingRotation tools, including rotated full-page floats

    Mark R. Galvin/K Nelson LATEX and Beamer

  • Recommended Way of Setting up Your Files

    ProjectFolder

    ? ?

    -

    -

    -

    -

    -

    -

    -

    main.tex

    main.log

    main.aux

    main.toc

    main.lof

    main.lot

    main.bbl

    and otherscreated by

    LATEX

    LiteratureSearch

    -

    -

    -

    -

    biblio file 1.bib

    biblio file 2.bib...

    biblio file n.bib

    Articles

    Includes

    -

    -

    -

    -

    -

    chapter 1.tex

    chapter 2.tex...

    chapter n.tex

    Figures

    -

    - figure n.xxx

    ...

    figure 1.xxx

    Tables

    -

    - table n.tex

    ...

    table 1.tex

    Mark R. Galvin/K Nelson LATEX and Beamer

  • Structure of a LATEX-document

    \documentclass[options]{style}

    \usepackage{graphicx,float,wrapfig}

    \usepackage{fancyhdr}

    \author{}

    \title{}

    \date{}

    %End of the preamble

    \begin{document}

    \maketitle

    \tableofcontents

    \chapter{}

    ...

    \end{document}

    Mark R. Galvin/K Nelson LATEX and Beamer

  • Class options

    Font size 10pt — 11pt — 12pt...Paper size a4paper — legalpaper...equations fleqn, leqno

    title titlepage — notitlepagecolumns onecolumn — twocolumnprinting oneside — twoside

    Mark R. Galvin/K Nelson LATEX and Beamer

  • Input characters

    Some characters have special meaning in TEX, if you needthem they have to be entered as TEX-commands:

    \ start command $\backslash$note: \\ = newline

    $ toggle math modus \$& tabulator \&% rest of line comment \%# \#˜ \textasciitilde| vert. lines in table \textbar

    start subscript \_ˆ start superscript \textasciicircum{ } command delimiter \{ \}[ ] command delimiter $[ ]$“ ” quotation marks ‘‘ ’’>< tabbing $>

  • Sectioning commands

    \part{}\chapter{}\section{}\subsection{}\subsubsection{}\paragraph{}

    Mark R. Galvin/K Nelson LATEX and Beamer

  • Descriptive lists

    Three animals you should know about are:gnat: A small animal, found in the North Woods, that

    causes no end of trouble.gnu: A large animal, found in crossword puzzles, that

    causes no end of trouble.armadillo: A medium-sized animal, named after a

    medium-sized Texas city which causes no end oftrouble.

    \begin{description}

    \item[gnat:]{A small animal, found in the North

    Woods, that causes no end of trouble.}

    \item[gnu:]{A large animal, found in crossword

    puzzles, that causes no end of trouble.}

    \item[armadillo:]{A medium-sized animal, named

    after a medium-sized Texas city which causes

    no end of trouble.}

    \end{description}

    Mark R. Galvin/K Nelson LATEX and Beamer

  • Enumerated lists

    These are the main points:1 first item2 second item3 third item

    1 first sub-item2 second sub-item

    These are the main points:

    \begin{enumerate}

    \item{first item}

    \item{second item}

    \item{third item

    \begin{enumerate}

    \item{first sub-item}

    \item{second sub-item}

    \end{enumerate} }

    \end{enumerate}

    Mark R. Galvin/K Nelson LATEX and Beamer

  • Table (a float: not used on slides)

    \begin{table}

    \caption{The fastest man in the world:

    Some of his possibilities}

    \label{tab:fast}

    \centering

    \begin{tabular}{|l|c|r|}\hline

    Discipline & distance (m) & time (min) \\\hline

    Running & 100 & 5 \\

    Swimming & 50 & 30 \\

    Cycling & 1000 & 20 \\\hline

    \end{tabular}

    \end{table}

    In the text the table can be referenced with: see table\ref{tab:fast} on page \pageref{tab:fast}.

    Mark R. Galvin/K Nelson LATEX and Beamer

  • Building Tables

    Use the matlab function at matlab centralhttp://www.mathworks.com/matlabcentral/

    fileexchange/13082

    From excel to LATEX: Excel2LATEXTEXShop: Matrix PanelLook it up on the internet or write your own function

    Mark R. Galvin/K Nelson LATEX and Beamer

    http://www.mathworks.com/matlabcentral/fileexchange/13082http://www.mathworks.com/matlabcentral/fileexchange/13082

  • Graphics

    \includegraphics[height=0.15\textheight]{figures/campus}

    Requires \usepackage{graphicx}Several file formats possible depending on dvi-driver. ForpdfLaTeX pdf, png, jpg.Convert other formats e.g. with IrfanView or Gimp.other optional arguments like width, angle, size

    Mark R. Galvin/K Nelson LATEX and Beamer

  • Figures

    Figure 1: A view of our campus.

    \begin{figure}

    \centering

    \includegraphics[height=0.15\textheight]{figures/campus}

    \caption{A view of our campus. }

    \label{fig:Campus}

    \end{figure}

    Like table, figure is a floating environment that has no meaningin slides. In a document, the figure would appear as above witha sequential figure number. Cross-referencing works as withtables.

    Mark R. Galvin/K Nelson LATEX and Beamer

  • Creating Figures

    Figure Tools:1 Use package tikz2 pdf printer3 Matlab

    n=30;for k=1:n

    figure(k) % changes active figure to figure number kset(k,'PaperUnits','normalized') % set up for normalized unitsset(k,'PaperOrientation','landscape') % set paper orien tation to landscapeset(k,'PaperType', 'usletter' ) % set paper size to uslette rset(k,'PaperPosition',[0 0 1 1]) % set the figure to fill the entire pageprint('-dpdf','-r600', k) % print using the pdfwrite drive r, 600 dpi resolution

    end

    Mark R. Galvin/K Nelson LATEX and Beamer

  • Aligning equations

    f(x) = cos x (1)f ′(x) = − sin x (2)

    ∫ x

    0f(y)dy = sin x (3)

    \begin{align}

    f(x) & = \cos x \\

    f’(x) & = -\sin x \\

    \int_{0}ˆ{x} f(y)dy & = \sin x

    \end{align}

    Mark R. Galvin/K Nelson LATEX and Beamer

  • Math Tricks

    1 Just type it2 Use Maxima or Mathematica3 Drag and Drop from the internet into LATEXiT4 Math Type5 Continually Update a Library of Equations

    Mark R. Galvin/K Nelson LATEX and Beamer

  • The Easiest Way to Write a Thesis

    Example

    Mark R. Galvin/K Nelson LATEX and Beamer