Latex crash course

29
Reproducible research with L A T E X+R (for PhD students) Tomislav Hengl ISRIC — World Soil Information, Wageningen University In Wageningen, 26 September 2013

Transcript of Latex crash course

Page 1: Latex crash course

Reproducible research with LATEX + R(for PhD students)

Tomislav Hengl

ISRIC — World Soil Information, Wageningen University

In Wageningen, 26 September 2013

Page 2: Latex crash course

Outline I

Important pointsDisclaimerThe programmeReproducible research is beautiful!Software in useWeb-services of interest

What is TEX?TEX philosophyWhat is LATEX?

LATEX versus MS WordComparisonLiterature

In Wageningen, 26 September 2013

Page 3: Latex crash course

What you need to know about me

I I am not really familiar with TEX programming (I neverdeveloped any LATEX package).

I LATEX has a steep learning curve.

I I also still use Google docs and MS Word (e.g.to write shortdocuments).

I LATEX comes (as any GNU) without any warranty.

In Wageningen, 26 September 2013

Page 4: Latex crash course

The course programme (1)

Block 1 (2 hours)

I Introduction to TEX (philosophy, history).

I Installation of software and first steps.

I Common LATEX commands (graphics, tables, BibTEX, math).

I Generate your first document with LATEX.

In Wageningen, 26 September 2013

Page 5: Latex crash course

The course programme (2)

Block 2 (2 hours)

I Collaborative writing using LATEX— the DropBox approach.

I Collaborative writing using LATEXon-line LATEXeditors(ShareLaTeX, LaTeXLab)

I Finding the right template for a PhD thesis

I Writing a PhD thesis with LATEX(tips and tricks).

In Wageningen, 26 September 2013

Page 6: Latex crash course

The course programme (3)

Block 3 (2 hours)

I Reproducible research — why? how? where?

I Combining R and LATEXcode -> Sweave.

I Preparing presentations using the Beamer package.

I Converting LATEXdocs to MS Word and HTML.

In Wageningen, 26 September 2013

Page 7: Latex crash course

What is reproducible research?1

Ideally, each paper submitted for publication that contains sometype of statistical analysis or summaries of results should allow forchecking / validation.Anybody should be able to reproduce your results. . . of course —this is one of the main principles of science! But most of thearticles you find (>95%) do not satisfy the reproducibility principle!Science is still largely based on trust and authorities.

1https://en.wikipedia.org/wiki/Reproducibility

In Wageningen, 26 September 2013

Page 8: Latex crash course

Kligl & Bates (2011)

In Wageningen, 26 September 2013

Page 9: Latex crash course

Reproducible research is beautiful!

In Wageningen, 26 September 2013

Page 10: Latex crash course

Another example: JSS

In Wageningen, 26 September 2013

Page 11: Latex crash course

See also: UG4A

In Wageningen, 26 September 2013

Page 12: Latex crash course

Another leitmotif of this course: collaboration

I The best papers are the ones written through creative teamwork — creative brainstorming and discussion!

I But how to collaborate on LATEXdocuments?

I And how to monitor progress? (or “who do I turn ontrack-changes in LATEX?!”)

In Wageningen, 26 September 2013

Page 13: Latex crash course

Software

You should have installed these already!

I MikTEX (LATEX engine);

I WinEdt (TEX editor);I (recommended) a number of WinEdt plugins:

I JabRef — references editor;I BibTEX menu — WinEdt menu for references;I MathType — Equation editor;I R-Sweave — full WinEdt–R integration;

I optional: Scientific Word — the commercial programme forproducing LATEX documents under Windows; word2tex — ashareware programme that converts MS WORD documents toLATEX.

In Wageningen, 26 September 2013

Page 14: Latex crash course

Websites (on-line services)

You can make an account and test things out

I On-line TEXeditor: https://www.sharelatex.com;

I Shared documents: http://DropBox.com;

I Annotation of PDF docs: http://a.nnotate.com;

I On-line equation editors;

In Wageningen, 26 September 2013

Page 15: Latex crash course

TEX history I

I In 1978, Donald Knuth (one of the most famous and wellrespected computer scientists) embarked on a project tocreate a typesetting system, called TEX (pronounced ‘tech’),after being disappointed with the quality of his acclaimed TheArt of Programming series.

I TEXis an abbreviation of τεχνη (TEXNH — techne), Greekfor both “art” and “craft”, which is also the root word of‘technical’2.

I Around 10 years later, he froze the language after originallyanticipating spending a single year!

In Wageningen, 26 September 2013

Page 16: Latex crash course

TEX history III In the mid-80s Leslie Lamport created a set of macros that

abstracted away many of the complexities (this allowed for asimpler approach for creating documents, where content andstyle were separate). This extension became LATEX(pronounced ‘lay-tech’);

I MiKTEX (pronounced ‘mick-tech’) is an up-to-dateimplementation of TEX and related programs for Windows.

2https://en.wikipedia.org/wiki/TeX

In Wageningen, 26 September 2013

Page 17: Latex crash course

LATEXis not latex!

6=

In Wageningen, 26 September 2013

Page 18: Latex crash course

TEX philosophy

Donald Knuth designed TEXwith two main goals in mind:

1. (perfectionism) to allow anybody to produce high-qualitybooks using a reasonably minimal amount of effort, and

2. (continuity) to provide a system that would give exactly thesame results on all computers, now and in the future.

The creator “offers monetary awards to people who find and reporta bug in TEX. The award per bug started at $2.56 (one‘hexadecimal dollar’) and doubled every year until it was frozen atits current value of $327.68. . . recipients have been known toframe their check as proof that they found a bug in TEXrather thancashing it.”

In Wageningen, 26 September 2013

Page 19: Latex crash course

What is LATEX?

I essentially a markup language;

I analogous to HTML with CSS;

I programming environment with many contributed packagesand styles;

I renders the content into a document (PDF);

I the code must be error-free from the beginning till the end!otherwise you do not see any PDF.

In Wageningen, 26 September 2013

Page 20: Latex crash course

Who is it for?

I Anybody writing anything maths related will not find a richerand better quality system.

I Anybody planning to write research articles, PhD or MScthesis and make professional and stable overheads;

I If you are in academia, you really ought to be using it!

I Even WikiPedia uses LATEX for rendering any formulas thatappear on their site.

I See also: “LATEX isn’t for everyone but it could be for you” byAndy Roberts.

In Wageningen, 26 September 2013

Page 21: Latex crash course

Why TEX?

I . . . portability, lightness, security;

I it is easier than XML (and has less bugs);

I it is for free

I it is one of the most sophisticated digital typographicalsystems in the world (MS Word is not a press software!);

I You can get LATEX to do just about anything you can think of!(it’s just a question of time / effort)

In Wageningen, 26 September 2013

Page 22: Latex crash course

TEX saves time

I focus on content, let LATEX bother about the layout;

I the software takes care of the actual typesetting, structuring,numbering, referencing and cross-referencing, indexing andpage formatting;

I compile documents in PDF (export to HTML, RTF);

I hyphenation, typesetting, fine-tuned control;

In Wageningen, 26 September 2013

Page 23: Latex crash course

LATEX versus MS Word

MS Word

I WYSIWYG world;

I XML;

I nonstandard styles;

I not-suited for large(collaborative)documents;

I compatibility problems(MS Word 97, 2000, XP,2003, 2007);

LATEX

I code world;

I TEX language;

I standard styles;

I suited for largecollaborative documents;

I the syntax staid the sameever since the beginning!

. . .and the winner is. . .

In Wageningen, 26 September 2013

Page 24: Latex crash course

MS Word

MS Word does in fact have a similar Styles feature (but peopledon’t often know it exists).Microsoft has a software to prepare documents for press —Microsoft Office Publisher, but even this can not be compared withe.g.Adobe InDesign (do you have money to use this software?)

In Wageningen, 26 September 2013

Page 25: Latex crash course

TEX versus MS Word3

3http://www.pinteric.com/miktex.html

In Wageningen, 26 September 2013

Page 26: Latex crash course

TEX versus MS Word

Andy Roberts’ Laws on Word:

1. Likelihood of a crash is directly proportional to the importanceof a document.

2. Likelihood of a crash is inversely proportional to the time leftbefore its deadline.

3. Likelihood of a crash is directly proportional to the durationsince you last saved.

4. Likelihood of you throwing your computer out of the windowis directly proportional to the number of times Clippy pops up.

5. That’s enough laws for now. . .

See also: “LATEX vs.MS Word”

In Wageningen, 26 September 2013

Page 27: Latex crash course

Literature

Lamport, L., 1994. LATEX: A Document Preparation System.Addison-Wesley, 291 p.

Oetiker, T. 2008. The (Not So) Short Introduction to LATEX2e.self-published, 155 p.

Talbot, N.L.C. 2013. Using LaTeX to Write a PhD Thesis,Dickimaw LATEXSeries

LATEX on wikibooks.http://en.wikibooks.org/wiki/LaTeX

In Wageningen, 26 September 2013

Page 28: Latex crash course

Layout galleries

I The TEX showcase;

I Page and chapter headings by Vincent Zoonekynd;

I LATEX font catalogue;

I Text Processing using LATEX by University of Cambridge

I Copernicus publications (HESS);

In Wageningen, 26 September 2013

Page 29: Latex crash course

LATEX to HTML/KML

I convert your LATEX document to HTML (install TtH);

I install some KML editor (or use WinEdt);

I Put the slides as HTML in the description field;

I to get some idea what you can do with KML, look at theKML interactive sampler and/or Google Earth Outreach;

I You can also convert from LATEX document to Wiki (e.g.usingthis Python script);

In Wageningen, 26 September 2013