Introduction to LaTeX

advertisement
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
• Installation of stand-alone version
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
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
How to make a document
source
compiler
• Writer only makes source
• Software creates document
document
How to make a document
source
compiler
document
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)
How to make a document
source
compiler
document
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/
How to make a document
source
compiler
document
TeX distributions come with different programs to obtain different output formats.
We will use pdflatex to create pdf documents
How to make a document
source
compiler
document
• Stand-alone version
• Online editors & compilers:
WriteLaTeX, ShareLaTeX: https://www.sharelatex.com
• Graphical interface combining WISYWIG with WYSIWYM: http://www.lyx.org
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?
The main file: XXX.tex
The 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)
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.
References
1. 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 style
1. Include the natbib package
2. Insert a \bibliograhystyle and \bibliography command
4. Add the citation in the tekst using the \cite command
Figures
The 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}
Figures
Always 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.
Figures
Or 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.
Figures
Possible 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/
Tables
To 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.
Math, Chemistry & Bio stuff
LaTeX 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
Presentations in LaTeX
Note: There is a lot of discussion, even within the LaTeX community,
About the use of LaTeX for making presentations – although very good
Results can be obtained for scientific presentations, some argue that
It’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!
Download