LATEX and Beamer: Open Source Alternatives to Microsoft Office 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 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 making packages that use the LATEX markup format and the TEX engine to 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 the human-readable source code is made available to the user of the software, who can then modify the code in order to fit the software to the user’s needs. The source code is the set of written 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 the software. In this manner the software evolves at a rate unmatched by traditional .

Where is it? Hiding on the internet. IfGoogle doesn’t find it, try the 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 need Way more features than you need Freeware and shareware usually come with baggage You can’t afford custom software but with F/OSS . . . An equivalent to most every major software package exists, pre-compiled and ready to use No proprietary issues, high degree of compatibility among F/OSS packages Most “established” packages have user groups willing to help you understand how to use or modify the software It’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 great Usually less polished than commercial software Every user is expected to be a beta tester May not (yet) be optimized for speed Sometimes limited (or no) documentation Few F/OSS packages are standards Compatibility with commercial software may lag one or more generations behind

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

Mark R. Galvin/K Nelson LATEX and Beamer F/OSS EssentialsI Some Commercial Equivalents:

Commercial F/OSS Website Microsoft Office Open Office www.openoffice.org Microsoft Internet Explorer Mozilla Firefox www.getfirefox.com www.mozilla.org/thunderbird Microsoft Word Abiword www.abisource.com Norton Antivirus ClamWin www.clamwin.com GIMPShop www.gimpshop.net Windows Media Player VLC Player www.videolan.org/vlc WinFTP Filezilla filezilla.sourceforge.net Adobe Acrobat PDFCreator OSUWare CD Google Earth NASA Worldwind worldwind.arc.nasa.gov Mathmatica Maxima maxima.sourceforge.net MATLAB Octave www.gnu.org/software/octave

Mark R. Galvin/K Nelson LATEX and Beamer F/OSS EssentialsII

Other Good Stuff I Like:

Package Description Website MiKTeX Windows LATEX implementation www.miktex.org RedHat www.redhat.com PovRay Ray-tracing program www.povray.org TrueCrypt Encrypt memory stick www.truecrypt.org Handbrake Copy DVD to your hard drive handbrake.m0k.org JabRef Bibliography reference manager jabref.sourceforge.net True Combat: Elite Multiplayer combat/action www.truecombatelite.net

Mark R. Galvin/K Nelson LATEX and Beamer The TEX Document Typesetting System

TEX was created by Donald Knuth (and others) to typeset computer programming manuscripts Catalyst was obsolescence of hot press typesetting First release took over ten years to complete Included METAFONT font description system which allows the designer to describe characters algorithmically TEX markup language is primitive by today’s standards, but was very advanced when first released Copyright vested with American Mathematical Society Availability of source code led to other TEX dialects Still others created markup formats (i.e., have collections of macros written in one of the TEX dialects) to simplify writing a TEX-based document LATEX is most common plain TEX markup format, but many others based on the other TEX dialects exist What 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 Engines TEX, pdfTEX, XeTEX, LuaTEX, etc. These are the actual executable binaries which implement the different TEX dialects. Formats LATEX, plain TEX, etc. These are the TEX-based languages in which you actually write documents. Packages geometry, 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 vast majority of packages in the TEX world. Front ends Emacs, TEXShop, TEXnicCenter, WinEdt, LEd, etc. These editors are what you use to create a document file. TEX documents are independent of any particular editor; the actual TEX typesetting program itself does not care how you created your file. This is in stark contrast to programs such as Microsoft Word, where editing and typesetting are fundamentally intertwined. Distributions MiKTEX, TEX Live, etc. These are the large collections of TEX-related software 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 quality Output is, typographically, far better than any of the alternatives Output device independence Formatting applied does not depend on the printer designated as “current” Portability Runs on virtually any operating system; output formats are not proprietary Document longevity No planned obsolescence here. . . Macros and other programmatic features LATEX lets the user define macros that can be used repeatedly Mathematical typesetting There’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 package writers provide contact information (and actually answer , even if half-a-world away)

Mark R. Galvin/K Nelson LATEX and Beamer Some Examples Photoelectric Effect (Author: Poul Riis, created using Tikz)

Incoming γ-photon

Photoelectron from an + inner shell +++

Mark R. Galvin/K Nelson LATEX and Beamer Some Examples Compton Scattering (Author: Poul Riis, created using Tikz)

Incoming γ-photon Scattered electron from an outer shell

Scattered γ-photon

+ +++

Mark R. Galvin/K Nelson LATEX and Beamer Some Examples Pair Production (Author: Poul Riis, created using Tikz)

Positron Incoming γ-photon

+ Electron +++

Mark R. Galvin/K Nelson LATEX and Beamer Some Examples Pressurized Water Reactor (Author: Gloria Faccanoni, created using Tikz)

Containment structure Water vapor

Reactor Pressurizer vessel Control rods Turbine Steam Steam generator (heat change) Generator

Water coolant Cooling (330 ◦) Condenser Pump tower Reactor Liquid core Cooling water

Water coolant Pump (280 ◦C) Pump

Pressurized water Water and steam Water (primary loop) (secondary loop) (cooling loop)

Mark R. Galvin/K Nelson LATEX and Beamer

1 Some Examples Nerdy Time Plot of Neutronics Project Data

Mark R. Galvin/K Nelson LATEX and Beamer Some Examples A Sexy Piece of a Neutronics Project Writeup

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

L ℓ+1 ℓ ˜ ℓ+1 ˜ ℓ+1 k = k dx ν1Σ f,1(x)φ1 (x) + ν2Σ f,2(x)φ2 (x) Z0 h i

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

L/2 L ℓ+1 ℓ ℓ+1 ℓ+1 ℓ+1 ℓ+1 k = k dx ν1Σ f,1(x)φ˜ (x) + ν2Σ f,2(x)φ˜ (x) + dx ν1Σ f,1(x)φ˜ (x) + ν2Σ f,2(x)φ˜ (x)  1 2 Node 1 1 2 Node 2  Z0 LZ/2   h i h i   L/2 L/2    ℓ  ℓ+1 ℓ ℓ+1  = k dx ν1Σ f,1(x)φ˜ (x) + k dx ν2Σ f,2(x)φ˜ (x)  1 Node 1   2 Node 1  Z0  Z0   h i   h i   L   L       ℓ ℓ+1   ℓ ℓ+1  +k dx ν1Σ f,1(x)φ˜ (x) + k dx ν2Σ f,2(x)φ˜ (x)  1 Node 2   2 Node 2  LZ/2  LZ/2   h i   h i             

Mark R. Galvin/K Nelson LATEX and Beamer What is Bad About LATEX? Some find it a turn-off, others a challenge. . .

More moving parts Using 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 commands Learning the markup commands takes time, and can be frustrating Previewing delay There is a delay between typing something in the editor and seeing the result in the document previewer Possibility of syntax errors Unlike in a WYSIWYG word processor, it is possible to create a tex file that LATEX will reject, cryptically complaining of a syntax error Adding new fonts You can’t just download some ttf (TrueType Font) file off the web and start using it (but then again, most fonts aren’t worth using anyway) Lack of support for some document formats If 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 MakeIndex Used for producing a sorted index from unsorted raw data. Also processes glossaries, acronyms, and other lists of “location-defined” entries. (Standard in every TEX distribution.) BiBTEX: Tool for formatting lists of references. Most popular citation styles are supported. (Standard in every TEX distribution.) JabRef Reference 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 and searching BiBTEX files. Beamer Highly customizable presentation package for LATEX. Capable of producing either a document (article, report, etc.) or a presentation from the same content, depending on how you process the content through the TEX engine. (Standard in every TEX distribution.) Excel2LATEX Excel add-in that formats spreadsheet data as a LATEX table. Tth TEX to HTML converter. Very useful if you want to put a paper on-line with minimal processing.

Mark R. Galvin/K Nelson LATEX and Beamer Essential LATEX Packages graphicx Enhanced support for graphics xcolor Driver-independent color extensions for LATEX and pdfLATEX overpic Combine LATEX commands over included graphics geometry Flexible and complete interface to document dimensions movie15 Multimedia inclusion package. amsmath AMS mathematical facilities and features for LATEX colortbl Add color to LATEX tables fancyhdr Extensive control of page headers and footers rotating Rotation tools, including rotated full-page floats

Mark R. Galvin/K Nelson LATEX and Beamer Recommended Way of Setting up Your Files

Project Folder

? ?

Literature - main.tex Includes Search - main.log - biblio file 1.bib - chapter 1.tex - main.aux - biblio file 2.bib - chapter 2.tex - main.toc . . . . - main.lof - biblio file n.bib - chapter n.tex - main.lot - - figure 1.xxx main.bbl - - . Articles Figures . and others - figure n.xxx created by - LAT X table 1.tex E - . Tables . - table n.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 — notitlepage columns onecolumn — twocolumn printing oneside — twoside

Mark R. Galvin/K Nelson LATEX and Beamer Input characters

Some characters have special meaning in TEX, if you need them 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 $> <$

Mark R. Galvin/K Nelson LATEX and Beamer 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 of trouble. \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 item 2 second item 3 third item 1 first sub-item 2 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 central http://www.mathworks.com/matlabcentral/ fileexchange/13082 From excel to LATEX: Excel2LATEX TEXShop: Matrix Panel Look it up on the internet or write your own function

Mark R. Galvin/K Nelson LATEX and Beamer Graphics

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

Requires \usepackage{graphicx} Several file formats possible depending on dvi-driver. For pdfLaTeX 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 meaning in slides. In a document, the figure would appear as above with a sequential figure number. Cross-referencing works as with tables.

Mark R. Galvin/K Nelson LATEX and Beamer Creating Figures

Figure Tools: 1 Use package tikz 2 pdf printer 3 Matlab

n=30; for k=1:n figure(k) % changes active figure to figure number k set(k,'PaperUnits','normalized') % set up for normalized units set(k,'PaperOrientation','landscape') % set paper orientation to landscape set(k,'PaperType', 'usletter' ) % set paper size to usletter set(k,'PaperPosition',[0 0 1 1]) % set the figure to fill the entire page print('-dpdf','-r600', k) % print using the pdfwrite driver, 600 dpi resolution end

Mark R. Galvin/K Nelson LATEX and Beamer Aligning equations

f(x) = cos x (1)

f 0(x) = sin x (2) x − f(y)dy = sin x (3) Z0

\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 it 2 Use Maxima or Mathematica 3 Drag and Drop from the internet into LATEXiT 4 Math Type 5 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