<<

TheLATEX document preparation system

Dr Engelbert Buxbaum

Introduction

Structure of a LATEX TheLAT X document preparation system document E Basic commands

Structuring text

Maths

Dr Engelbert Buxbaum Changing the layout

Specialties Department of Biochemistry, RUSM The departmental handout

July 2008

1 TheLATEX document Name of the game preparation system Dr Engelbert Buxbaum

Introduction Advantages and disadvantages Resources

Structure of a LATEX document TEX typesetting system developed by Donald E. Basic commands Knuth () to create beautiful Structuring text documents, especially those containing maths. Maths TEX is free software with copyright vested in the Changing the layout American Mathematical Society. Specialties The departmental LATEXT EX-macroprocessor written by Leslie Lamport, handout which implements a markup-language (similar: HTML, XML). Users can concentrate on the structure of their document rather than on formatting.

2 TheLATEX document Typographic design preparation system Dr Engelbert Buxbaum

Introduction Advantages and disadvantages Resources

Structure of a LATEX document

Basic commands

Structuring text

Maths I craft that needs to be learned Changing the layout I not about esthetics but about function: Books are read, Specialties The departmental not displayed in a museum handout

3 TheLATEX document Advantages preparation system Dr Engelbert Buxbaum

I Several professional styles are available that make Introduction Advantages and documents look “like printed”. Changing style requires disadvantages Resources changing one single line in the document, consistency is Structure of a LATEX ensured. document Basic commands I High quality math typesetting Structuring text I Only a few commands to define the structure of text, no Maths knowledge of typography or book design required. Changing the layout I Complex scientific documents can be created Specialties The departmental automatically: handout I bibliography I index I crossreferences I table of contents, lists of figures, tables etc. I ... I Operating-system independent I Long-term storage of documents: ASCII rather than binary I Free software with source code available: Errors are corrected rapidly 4 TheLATEX document Disadvantages preparation system Dr Engelbert Buxbaum

Introduction Advantages and disadvantages Resources

Structure of a LATEX document

Basic commands

Structuring text I Learning curve Maths Changing the layout I Major changes in layout may require rewriting the style Specialties

file (blessing in disguise) The departmental handout I One gets an eye for all the bad documents out there

5 TheLATEX document Resources preparation system Dr Engelbert Buxbaum

Introduction Advantages and disadvantages Resources

Structure of a LATEX document

Basic commands

Software www.ctan.org, automatically selects nearest Structuring text

server Maths Help Usenet: comp.text. (also German: Changing the layout de.comp.text.tex) Specialties The departmental Introduction l2short available in various languages handout Literature The LATEX-companion (Mittelbach et al, 2004) Symbols Comprehensive symbol list from CTAN

6 TheLATEX document Boxes and glue preparation system Dr Engelbert Buxbaum

Introduction

Structure of a LATEX document classes

Basic commands

Structuring text

Maths I Box (letter) + Glue (space) + Box + ... = larger Box (word) Changing the layout Specialties I Words are treated as boxes to form lines, lines The departmental paragraphs and paragraphs pages handout I Glue can shrink and expand within limits

7 TheLATEX document Structure of a LAT X-document preparation system E Dr Engelbert Buxbaum

Introduction

%-*- TeX:US -*- % for text-editor Structure of a LATEX document \NeedsTeXFormat{LaTeX2e} % for TeX-system classes

\documentclass[options]{style} Basic commands

Structuring text \usepackage[latin1]{inputenc} Maths \usepackage[T1]{fontenc} Changing the layout Specialties

The departmental \author{} handout \title{} \date{}

\begin{document} \maketitle

\chapter{} ... \end{document}

8 TheLATEX document Document classes preparation system Dr Engelbert Buxbaum

Introduction

Structure of a LATEX document classes LATEX Koma-Script purpose Basic commands Structuring text

article scrartcl journal papers, short reports Maths report scrreprt longer text with several chap- Changing the layout ters, e.g. Specialties book scrbook books The departmental handout letter scrlttr2 letters beamer slide presentations sciposter conference posters Apart from Koma-Script another alternative style package is memoir. Also publisher-specific styles (e.g. Springer, Elsevier, Teubner etc.)

9 TheLATEX document Class options preparation system Dr Engelbert Buxbaum

Introduction

Structure of a LATEX document classes

Basic commands

Structuring text Font size 10pt | 11pt | 12pt... Maths Changing the layout

Paper size a4paper | legalpaper... Specialties equations fleqn, leqno The departmental handout title titlepage | notitlepage columns onecolumn | twocolumn printing oneside | twoside

10 TheLATEX document Input characters preparation system Dr Engelbert Buxbaum

Introduction Some characters have special meaning in TEX, if you need Structure of a LATEX them they have to be entered as T X-commands: document E Basic commands Special characters start command $\backslash$ Hypens & Cie Structuring text \ \\ note: = newline Maths

$ toggle math modus \$ Changing the layout

& tabulator \& Specialties % rest of line comment \% The departmental # \# handout ~ \textasciitilde | vert. lines in table \textbar _ start subscript \_ ^ start superscript \textasciicircum { } command delimiter \{ \} [] optional arguments $[ ]$ “ ” quotation marks ‘‘ ’’ >< tabbing $> <$

11 TheLATEX document Hypen, minus ... preparation system Dr Engelbert Buxbaum

Introduction

Structure of a LATEX document

Basic commands Special characters Hypens & Cie A horizontal line can mean a lot of things, depending on length Structuring text and thickness: Maths Changing the layout O-legs O-legs Specialties The departmental 10–18 o’clock 10--18 o’clock handout ja – oder nein? ja -- oder nein? yes—or no? yes---or no? 0, 1 and –1 0, 1 and --1

12 TheLATEX document Sectioning commands preparation system Dr Engelbert Buxbaum

Introduction

Structure of a LATEX document

Basic commands

Structuring text Sectioning I Fonts part{} Lists \ Tables and stuff I chapter{} Graphics \ I section{} Maths \ Changing the layout I subsection{} \ Specialties I subsubsection{} The departmental \ handout I paragraph{} \

13 TheLATEX document Breaking down large documents preparation system Dr Engelbert Buxbaum

Introduction

Structure of a LATEX document

Basic commands

Structuring text Sectioning Fonts Use separate files for, say, each chapter. One main file with Lists Tables and stuff limbo and commands to include the others: Graphics input{} reads file “as is” Maths \ Changing the layout include{} equiv. to clearpage input{} clearpage Specialties \ \ \ \ includeonly{} used in limbo to limit files included The departmental \ \ handout

14 TheLATEX document What is where? preparation system Dr Engelbert Buxbaum

Introduction

Structure of a LATEX document

Basic commands

Structuring text I tableofcontents Sectioning \ Fonts I listoffigures Lists \ Tables and stuff I listoftables Graphics \ Maths I Changing the layout I bibliographystyle{plainnat} Specialties \ I bibliography{references} The departmental \ handout I I printindex \

15 TheLATEX document Emphasizing preparation system Dr Engelbert Buxbaum

Introduction

Structure of a LATEX document textit{} italics, used for foreign words, species names \ Basic commands etc: Staph. aureus Structuring text Sectioning textsl{} slanted Fonts \ Lists emph{} used for emphasizing: this is not the case Tables and stuff \ Graphics textsc{} small caps, used for persons: Neil Armstrong \ Maths was the first man on the moon. Changing the layout textbf{} bold face: used to make something really stick Specialties \ The departmental out. handout textsf{} sans serif, often used as base font on slides. \ Also used for chemical equations. texttt{} typewriter, used for computer code or URLs: \ http://www.rossmed.edu.dm/ Note: Slides use sanserif font: slanted instead of italics!

16 TheLATEX document Font sizes preparation system Dr Engelbert Buxbaum

Introduction

Structure of a LATEX document

Basic commands \tiny microscopic font Structuring text \scriptsize very tiny font (subscripts) Sectioning Fonts \footnotesize tiny font (footnotes) Lists \small small font Tables and stuff Graphics \normalsize normal font Maths

\large large font Changing the layout \Large larger font Specialties The departmental \LARGE very large font handout \huge huge font \Huge very huge font Note: not a command: {\small foo bar}

17 TheLATEX document Simple lists preparation system Dr Engelbert Buxbaum

Please believe me: Introduction

I Structure of a LATEX Few swallows can turn winter into summer. document I Inside it’s colder than in the night. Basic commands I In the morning it pulls. Structuring text I At noon he pushes. Sectioning Fonts I In the evening she goes. Lists Tables and stu I ff Every nonsense must find an end. Graphics

Maths

Please believe me: Changing the layout

\begin{itemize} Specialties

\item{Few swallows can turn winter into summer.} The departmental \item{Inside it’s colder than in the night. handout \begin{itemize} \item{In the morning it pulls.} \item{At noon he pushes.} \item{In the evening she goes.} \end{itemize} } \item{Every nonsense must find an end.} \end{itemize}

18 TheLATEX document Descriptive lists preparation system Dr Engelbert Buxbaum

Three animals you should know about are: Introduction Structure of a LATEX gnat: A small animal, found in the North Woods, that document causes no end of trouble. Basic commands Structuring text gnu: A large animal, found in crossword puzzles, that Sectioning causes no end of trouble. Fonts Lists armadillo: A medium-sized animal, named after a Tables and stuff Graphics

medium-sized Texas city which causes no end of Maths

trouble. Changing the layout

Specialties \begin{description} The departmental handout \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}

19 TheLATEX document Enumerated lists preparation system Dr Engelbert Buxbaum

Introduction

These are the main points: Structure of a LATEX document 1. first item Basic commands 2. second item Structuring text Sectioning 3. third item Fonts Lists 3.1 first sub-item Tables and stuff 3.2 second sub-item Graphics Maths These are the main points: Changing the layout \begin{enumerate} Specialties The departmental \item{first item} handout \item{second item} \item{third item \begin{enumerate} \item{first sub-item} \item{second sub-item} \end{enumerate} } \end{enumerate}

20 TheLATEX document Tabbing preparation system Dr Engelbert Buxbaum

Introduction

Structure of a LATEX document If it’s raining Basic commands then put on boots, Structuring text Sectioning take hat; Fonts else smile. Lists Tables and stuff Leave house. Graphics Maths

Changing the layout \begin{tabbing} Specialties If \= it’s raining \\ The departmental \> then \= put on boots, \\ handout \> \> take hat; \\ \> else \> smile. \\ Leave house. \end{tabbing}

21 TheLATEX document Tabular preparation system Dr Engelbert Buxbaum

GG&A Hoofed Stock Introduction Structure of a LATEX Year Price Comments document 1971 97–245 Bad year for farmers in the west. Basic commands Structuring text 72 245–245 Light trading due to a heavy winter. Sectioning Fonts 73 245–2001 No gnus was very good gnus this year. Lists Tables and stuff \begin{tabular}{|r||c|p{2.5in}|} Graphics \hline Maths \multicolumn{3}{|c|}{\sc GG\&A Hoofed Stock} \\ Changing the layout \hline \hline Specialties \multicolumn{1}{|c||}{\bf Year} & \bf Price & \multicolumn{1}{c|}{\bf Comments}The departmental \\ \hline handout 1971 & 97--245 & Bad year for farmers in the west. \\ \hline 72 & 245--245 & Light trading due to a heavy winter. \\ \hline 73 & 245--2001 & No gnus was very good gnus this year. \\ \hline \end{tabular}

Note: this is a very bad example of a table!

22 TheLATEX document Table (a float: not used on slides) preparation system Dr Engelbert Buxbaum

Introduction

Structure of a LATEX \begin{table} document

\caption{The fastest man in the world: Basic commands

Some of his possibilities} Structuring text \label{tab:fast} Sectioning Fonts \centering Lists \begin{tabular}{|l|c|r|} Tables and stuff \toprule Graphics Disciplin & distance (m) & time (min) \\ Maths \midrule Changing the layout Specialties Running & 100 & 5 \\ The departmental Swimming & 50 & 30 \\ handout Cycling & 1000 & 20 \\ \bottomrule \end{tabular} \end{table}

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

23 TheLATEX document Graphics preparation system Dr Engelbert Buxbaum

Introduction

Structure of a LATEX document

Basic commands

Structuring text Sectioning Fonts Lists Tables and stuff Graphics

Maths

Changing the layout \includegraphics[height=0.3\textheight]{Graphics/Campus3} Specialties

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

24 TheLATEX document Figures preparation system Dr Engelbert Buxbaum

Introduction

Structure of a LATEX document

Basic commands

Structuring text Sectioning Fonts \begin{figure} Lists \caption{A view of our campus. } Tables and stuff \label{fig:Campus} Graphics \centering Maths \includegraphics[height=0.3\textheight]{Graphics/Campus3} \end{figure} Changing the layout Specialties

The departmental Like table, figure is a floating environment that has no handout meaning in slides. Cross-referencing works as with tables.

25 TheLATEX document Text maths preparation system Dr Engelbert Buxbaum

Introduction

Structure of a LATEX document

Basic commands

Structuring text

Maths if a and b are legs of a right-angled triangle and c the Math environments Basic math commands hypotenuse, then c2 = a2 + b 2 (Theorem of Pythagoras). Changing the layout

Specialties if $a$ and $b$ are legs of a right-angled triangle The departmental and $c$ the hypotenuse, then $c^2=a^2+b^2$ (Theorem handout of Pythagoras).

26 TheLATEX document Display maths preparation system Dr Engelbert Buxbaum

Introduction

Structure of a LATEX document

Basic commands if a and b are legs of a right-angled triangle and c the Structuring text

hypotenuse, then Maths 2 2 2 c = a + b (1) Math environments Basic math commands (Theorem of Pythagoras). Changing the layout Specialties if $a$ and $b$ are legs of a right-angled triangle The departmental and $c$ the hypotenuse, then handout \begin{equation} c^2=a^2+b^2 \end{equation} (Theorem of Pythagoras).

27 TheLATEX document Formulas preparation system Dr Engelbert Buxbaum

q Introduction 5 2 3 Structure of a LATEX x x1 x + √y document

Basic commands x^5 x_1 \sqrt{x^2+\sqrt[3]{y}} Structuring text Maths Math environments Basic math commands ! Changing the layout 1 n Specialties 2 2 2 x +y +z n k The departmental x+y − handout

\frac{1}{\frac{x^2+y^2+z^2}{x+y}} {n\choose {n-k}}

Z∞ n 3 X x ai i=1 −∞ \int \limits_{-\infty}^{\infty}x^3 \sum_{i=1}^{n}a_i

28 TheLATEX document Aligning equations preparation system Dr Engelbert Buxbaum

Introduction

Structure of a LATEX document

Basic commands

Structuring text

f(x) = cosx (2) Maths Math environments f 0(x) = sinx (3) Basic math commands − Z x Changing the layout

f(y)dy = sinx (4) Specialties 0 The departmental handout

\begin{align} f(x) & = \cos x \\ f’(x) & = -\sin x \\ \int_{0}^{x} f(y)dy & = \sin x \end{align}

29 TheLATEX document Internal Counter + parameters preparation system Dr Engelbert Buxbaum

Introduction

Structure of a LATEX document Change parameters: Basic commands Structuring text

\setlength{\parindent}{0pt} Maths

\setlength{\parskip}{5pt plus 2pt minus 1pt} Changing the layout \addtolength{\textwidth}{60pt} Counters and parameters Distances Text position

Specialties Set counters: The departmental handout \setcounter{page}{0} \addtocounter{page}{10}

Output counter content: This is page 30. This is page \thepage.

30 TheLATEX document Horizontal distance preparation system Dr Engelbert Buxbaum

Introduction

Here we have2cm distance. Structure of a LATEX document Here we have \hspace{2cm} \SI{2}{cm} distance. Basic commands Structuring text

Maths

Changing the layout left right Counters and parameters Distances left\hfill right Text position Specialties

The departmental handout \, very small distance \enspace as wide as a number \quad as wide as a letter is heigh \qquad twice as wide as \quad \hfill a distance that can expand from 0 to ∞

31 TheLATEX document Vertical distance preparation system Dr Engelbert Buxbaum

Here Introduction

Structure of a LATEX document

Basic commands

Structuring text

Maths

Changing the layout is2cm distance. Counters and parameters Distances Here Text position Specialties

The departmental \vspace{2cm} handout

is \SI{2}{cm} distance.

\smallskip about1 /4 line \medskip about1 /2 line \bigskip about 1 line \vfill distance that can expand from 0 to ∞

32 TheLATEX document Centering text preparation system Dr Engelbert Buxbaum

Introduction

Structure of a LATEX document

In Basic commands

the Structuring text middle I don’t Maths feel Changing the layout Counters and parameters so marginalized Distances Text position

Specialties \begin{center} The departmental handout In\\ the\\ middle I don’t\\ feel\\ so marginalized\\ \end{center}

33 TheLATEX document Flushright text preparation system Dr Engelbert Buxbaum

Introduction

Structure of a LATEX document

Basic commands

Structuring text

Maths This is not a political statement Changing the layout Counters and parameters Distances Text position \begin{flushright} Specialties The departmental This is not a political statement handout \end{flushright}

34 TheLATEX document Indexing commands preparation system Dr Engelbert Buxbaum

Introduction

Structure of a LATEX document

Basic commands

Structuring text

Maths simple gnat\index{gnat} Changing the layout Specialties subtopics gnat\index{gnat!size of} The index List of acronyms page range \index{gnat|(}...\index{gnat|)} Bibliography Slide presentations reference \index{gnat|see{mosquito}} TeX-ing font gnat\index{gnat@\textit{gnat}} The departmental handout After first LATEX run, start makeindx to sort the index.

35 TheLATEX document Acronyms preparation system Dr Engelbert Buxbaum

Introduction

Structure of a LATEX document

Assume the following list of acronyms: Basic commands \begin{acronym} Structuring text Maths \acro{nfkb}[NF-\textkappa B]{nuclear factor Changing the layout

\textkappa B}, protein in gene regulation Specialties \end{acronym} The index List of acronyms Bibliography Slide presentations This will print as TeX-ing The departmental NF-κB: nuclear factor κB, protein in gene regulation handout Then acf{nfkb} nuclear factor κB (NF-κB) \ acs{nfkb} NF-κB \ acl{nfkb} nuclear factor κB \

36 TheLATEX document BibTeX preparation system Dr Engelbert Buxbaum

Database for literature references in ASCII-format. Can be Introduction

produced from many programs like EndNote or RefMan, also Structure of a LATEX from PubMed, Google Scholar (set preferences!) etc. document Basic commands

@article{Alb-76, Structuring text

AUTHOR= {W.J. Albery and J.R. Knowles}, Maths

TITLE= {Evolution of enzyme function and the Changing the layout development of catalytic efficiency}, Specialties JOURNAL= {Biochemistry}, The index List of acronyms VOLUME= {15}, Bibliography YEAR= {1976}, Slide presentations TeX-ing PAGES= {5631-5640}, The departmental ABSTRACT= {Catalytic efficiency constant kcat/Km handout defined }, DOI= {10.1021/bi00670a032}, LANGUAGE= {engl} }

Similar for books, chapters, reports, thesis etc. In the text use cite{Alb-76}. After first LATEX-run start to create the bibliography.\ 37 TheLATEX document Beamer-slides preparation system Dr Engelbert Buxbaum

Introduction

Structure of a LATEX document

Basic commands

Structuring text

Maths

Changing the layout begin{frame} Specialties \ The index frametitle{} List of acronyms \ Bibliography ... Slide presentations end{frame} TeX-ing \ The departmental handout

38 TheLATEX document T Xing preparation system E Dr Engelbert Buxbaum

Introduction

Structure of a LATEX document

Basic commands

Structuring text

Always use the sequence: Maths LATEX produces the necessary intermediate files Changing the layout Specialties makeindx sort the index The index List of acronyms bibtex create the bibliography Bibliography Slide presentations A LTEX include bibliography and index, resolve TeX-ing cross-references The departmental handout LATEX resolve remaining cross-references Note: using pdfLATEX instead of LATEX produces pdf-files directly.

39 TheLATEX document Packets used in dept. handout preparation system Dr Engelbert Buxbaum

acronym administration of acronyms Introduction Structure of a LATEX booktabs professional looking tables document chemarrow various types of arrows for equations Basic commands color colored text Structuring text eufrak font for arrays + vectors Maths graphicx inclusion of diagrams Changing the layout hyperref use cross-referencing facilities of pdf Specialties The departmental isodate standard conform dates handout isotope isotope[13]C= 13C kpfonts works\ better than the original fonts makeidx index generation natbib clean handling of bibliography siunitx SI, num, ang thumb chapter\ \ thumbs\ upgreek textalpha= α instead of α wasysym,marvosym special\ symbols like |, ~

40 TheLATEX document Getting consistent output preparation system Dr Engelbert Buxbaum

Introduction

Structure of a LATEX document

Basic commands

Structuring text I Maths chemical{CH_2 double CH single OH}=CH 2=CH OH \ \ \ − Changing the layout I ph= pH, similar for pkw, pka, poh, pI \ \ \ \ \ Specialties I Name{Maude Leonora Menten}= Maude Leonora The departmental handout M\ enten I skalar{x}= x, similar for array, vektor, set. Note the \list of variables used in the\ appendix.\ \ I SI{1}{cm}=1cm, num{10000}= 10000, ang{1;2;3}= \ \ \ 1°20300.

41