Top Banner
INTRODUCTION TO Jeroen Buijs
19

Introduction to

Jan 02, 2016

Download

Documents

Introduction to. Jeroen Buijs. Contents. Today What is LaTeX ? What do we need? Our first example : The Nature LaTeX template Writing articles in Latex Basic commands References Figures Tables Math, Chemistry and Life Sciences Next Presentations in LaTeX Posters in LaTeX - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Introduction to

INTRODUCTION TO

Jeroen Buijs

Page 2: Introduction to

Contents• Today

• What is LaTeX? What do we need?• Our first example: The Nature LaTeX template• Writing articles in Latex

• Basic commands• References• Figures• Tables• Math, Chemistry and Life Sciences

• Next• Presentations in LaTeX• Posters in LaTeX• Installation of stand-alone version

Page 3: Introduction to

What is (La)TeX?• TeX is essentially a Markup Language

(like HTML, XML and RTF)

• TeX written in 70´s• TEX is a typesetting language written by Donald Knuth.• Plain TEX easy for simple documents

(without equations, chapters etc).• Otherwise very tricky.

• LaTeX is an extension of TeX• Macro packages to make TeX easier to use

Page 4: Introduction to

Latex vs. Word Processors• WYSIWYG - WYMIWYG• High typeset quality• Easy to include formulas & references• Source file format is not bounded to a particular OS or

platform• Implementations exist for all platforms (DOS, Windows,

Unix,..)• Free

• Steep learning curve• Requires compilation

Page 5: Introduction to

How to make a document

• Writer only makes source• Software creates document

sourcesource compilercompiler documentdocument

Page 6: Introduction to

How to make a documentsourcesource compilercompiler documentdocument

Several good LaTeX editors exist, e.g. • TeXniccenter, www.texniccenter.org (Windows only)• TeXstudio, http://texstudio.sourceforge.net/ (“all major OS”)• TeXmaker, http://www.xm1math.net/texmaker/ (Linux, MacOSx, Windows)

Page 7: Introduction to

How to make a documentsourcesource compilercompiler documentdocument

The set of programs that makes it possible to compile TeX and LaTeX documents is called a TEX distribution.

There are many (La)TeX distributions available for different operating systems. The most commonly used ones are• Windows

• proTeXt, http://www.tug.org/protext/ (includes MikTeX & TeXstudio))

• MixTeX, http://www.miktex.org• Mac: MacTeX, https://tug.org/mactex/ • Unix/GNU/Linux: TeX Live, http://www.tug.org/texlive/

Page 8: Introduction to

How to make a documentsourcesource compilercompiler documentdocument

TeX distributions come with different programs to obtain different output formats.We will use pdflatex to create pdf documents

Page 9: Introduction to

How to make a document

• Stand-alone version• Online editors & compilers:

WriteLaTeX, ShareLaTeX: https://www.sharelatex.com • Graphical interface combining WISYWIG with WYSIWYM: http://www.lyx.org

sourcesource compilercompiler documentdocument

Exercise 1: • Create an account on ShareLaTeX• Create a new article intended for Nature• In the Menu, make sure to select pdflatex and a spell checker• Compile and reflect on the relation source – final document• Where do you spell check your document?

Page 10: Introduction to

The main file: XXX.texThe main file contains a preamble and a document environment

The preamble • defines the class (and overall style) of your document by defining

the document class• tells the compiler which packages including all kinds of extra

(style) definitions you will use• contains your own definitions and commands

The document environment• Starts with \begin{document}, ends with \end{document}• Contains the contents of your document

There are other files involved as well. In this case:• A file defining the bibliography style (XXX.bst)• A file containing the content of the references (XXX.bib)

Page 11: Introduction to

The main file: XXX.tex

Exercise 2: • Change the title.• Change to two authors and add names.• Compile and download the PDF.

To learn more on packages and commands, let’s build our own article from scratch using the standard article class

Excellent reference for all “basic stuff”: The not so short introduction to LaTeX 2e

And if you’re stuck? Google!

Exercise 3: Using the standard article class, use (Share)LaTeX to create a pdf containing page 1 of the article “Recent insights into Candida albicans biofilm resistance mechanisms” by Mathé and Van Dijck.

Page 12: Introduction to

References1. Choose a bibliography style. For this journal, we use the chicago bibstyle.

Add this file to your project: http://mirrors.ctan.org/biblio/bibtex/contrib/chicago/chicago.bst

2. Create a bib file that will contain your references and add the first reference in BibTeX format, e.g. by using TeXMeD

3. Tell TeX to include the references at the end of the document in the right style1. Include the natbib package 2. Insert a \bibliograhystyle and \bibliography command

4. Add the citation in the tekst using the \cite command

Page 13: Introduction to

FiguresThe package graphicx can be used to include various graphic formats

(like pdf, jpg, png)

Figures are typically added as floats by the \begin{figure} … \end{figure} environment

In a multicol environment, floats are not allowed to float. We can use the float package and the option [H] to do so…:

Preamble: \usepackage{graphicx,float}

In the document:\begin{figure}[H]

\centering \includegraphics[width=0.9\linewidth]{qBasePlus_example} \caption{qBasePlus} \label{fig:qbp}

\end{figure}

Page 14: Introduction to

FiguresAlways use vector based graphic formats if possible.Easiest way is to convert them all to pdf

Exercise 4a: Add the figure qBasePlus_Example.pdf to your article.First use the blindtext package to add some extra text before and after the picture.Add a cross reference to the figure in your text.

Page 15: Introduction to

FiguresOr even better: let’s create our own graph from the raw data.We use the packages pgfplots and tikz to do this.

We don’t want to overload our main file, so we’ll put the figure in a seperate tex-file using the standalone document class, and include it afterwards.

Exercise 4b: Create a new file qbpfig.tex and use ybar (pgfplots package) to recreate the figure.Use the \includestandalone command of the standalone package to include the figure in your article.

Page 16: Introduction to

FiguresPossible result:

Advantages:• The font and style are the same as those of your text.• You can choose the most appropriate way to represent your data• Take a look here to get an idea of the strength of this package:http://www.texample.net/tikz/examples/all/

Page 17: Introduction to

TablesTo include tables, we can use table floats and the tabular environment.

For complex tables, you can use spreadsheet-to-latex converters,e.g. Excel2LaTeX, http://www.ctan.org/pkg/excel2latex

Exercise 4c: Add a table to your article.If you want, install and use a spreadsheet converter.Alternatively, you can use an online LaTeX table generator.

Page 18: Introduction to

Math, Chemistry & Bio stuffLaTeX is very good in typesetting mathematical and chemical formulas.

For ‘complexer’ mathematics, use the amsmath package.For chemical formulas, use the chemfig package

There also exist some bio-related packages, like:• texshade, for displaying the key changes in DNA• textopo, to draw transmembrane proteins from a SwissProt file

Exercise 5: (choose what you like)Add a Michaelis-Menten (or some other) equation to your article.Add the 2D formula for ethenol to your article.Check out one of the life science packages

Page 19: Introduction to

Presentations in LaTeXNote: There is a lot of discussion, even within the LaTeX community,About the use of LaTeX for making presentations – although very goodResults can be obtained for scientific presentations, some argue thatIt’s to cumbersome to produce good results without visual software…

The best way to create presentations in LaTeX, is by using the beamer class

Example!