james montgomery with contributions from many other users research school of computer science...

25
James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief explana tion

Upload: hortense-taylor

Post on 27-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief

James Montgomery with contributions from many other users

Research School of Computer Science

Australian National University

Tips and Tricks for

View brief explanation

Page 2: James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief

2

How LaTeX works (logical structure)

typesetting

document structure

Your .tex document

pdfLaTeXfrontend

XeTeXfrontend

...frontend

Page 3: James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief

3

Boxes: How TeX typesets

TeX tries to make things look ‘good’, so avoids ‘windows’ (last line of paragraph on next page) and ‘orphans’ (headings at end of page)

Floating environments (tables, figures, etc.) are boxes that cannot be split

\mbox command can prevent contents from breaking

Page 4: James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief

...

How LaTeX ‘works’

.cls

.tex

.aux

.toc

.bib

.out

.eps, .pdf

latexpdflatexxelatexetc.

.sty.sty.sty

.bbl

Lots and lots of files

4

Page 5: James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief

5

LaTeX processing steps

.tex

.aux.bib .bbl

>pdflatex doc.tex>pdflatex doc.tex>bibtex doc>pdflatex doc.tex>pdflatex doc.tex

Section 1

See Section on page .Knuth created TeX in 1978 .But Davenport is responsible for , which has given us much joy .

References

[1] L. Davenport. etc.[2] D. Knuth, etc.

2 3? ?[?]

[?][1]

[2]

Note: This has one more step than is necessary

Page 6: James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief

6

Workflows

•Emacs (with AUCTeX)

•Lyx• TeXnicCenter ( only)

•TeXlipse•TeXShop (in MacTeX on

)

•Vim (with Vim-LaTeX)

GitSVN

Use source control Use an editorwith syntax highlightingand code completion

svn-multito include SVN version data in drafts

It’s code, so when things don’t work, debug• \iffalse (or %comment)• Create a \comment{...} command

Page 7: James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief

7

Working with others

todonotesmarginal notes and figure placeholders

...

\input{james}

\input{mark}

\input{steve}

...

Option 1:Break up the

documentintro.tex

method.tex

results.tex

Option 2:Agree to work

on different parts

(and let source control handle

merging)

Margin notes using any convenient packagedoc.tex

james.tex

mark.tex

steve.tex

doc.tex

doc.tex

Page 8: James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief

8

Arrangingfloats

BibliographiesAlgorithms &code listings

Tables

Graphicscreation &

figuresMath

Inside your documentTitle

Ann Author

Heading 1

This is a sample document, illustrating key features The contents don’t matter, only that the key elements of a document be present. As Equation 1 shows, authors like to include equations.

(1)

Authors also include figures, tables, algorithms and code listings.

Algorithm 1

COBOL := 1while true add 1 to COBOLend

References

Knuth, D. E. (1984) The TeXbook. Addison-Wesley.

Lamport, L. (1994). LaTeX: A Document Preparation System. Addison-Wesley.

Figure 1. Has a caption

Col 1 Col 2 Col 3— — —— — —— — —— — —— — —

Table 1. Has a caption

Skip over these

Style

Page 9: James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief

9

Math

return

Many LaTeX editors provide menus of symbols

ntheorempredefined theorem & proof environments

amsmath, amsfonts, amssymbtheorems, better math fonts & symbols

mathtoolsfixes some things in amsmath; adds new functionality

Early on, have a cheat sheet handy

Page 10: James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief

Tables

Use an editor for complex tablese.g. LaTable on Windows

\begin{table}[t]\caption{Best combinations of $\alpha$ and $\gamma$ by problem from BBOB}\label{tab:bbob_results}\centering\begin{tabular}{@{}c@{\ \ }c@{\ \ }c@{\quad}c@{\quad}c@{\quad}c@{\quad}c@{\ \ }c@{\ }r@{\ }r@{}}\hline & & \multicolumn{2}{c}{Standard DE} & \multicolumn{2}{c}{Modified DE} & \multicolumn{2}{c}{Param.} & \\Set & fn & mean & stdev & mean & stdev & $\alpha$ & $\gamma$ & \%-diff & \textit{t}-test \\\hline & 1 & 0.00e+0 & 0.00e+0 & & & & & & \\%0.00e+0 & 0.00e+0 & 0.04 & 3 & 0\% & --- \\ & 2 & 6.44e+1 & 2.93e+2 & 8.12e-6 & 4.68e-6 & 0.1 & 2 & 100\% & 15\% \\1 & 3 & 2.29e+1 & 1.09e+1 & 1.42e+1 & 5.96e+0 & 0.1 & 3 & \textbf{38\%} & \textbf{0\%} \\ & 4 & 2.62e+1 & 8.33e+0 & 1.90e+1 & 6.08e+0 & 0.04 & 1 & \textbf{28\%} & \textbf{0\%} \\ & 5 & 2.16e+0 & 8.59e+0 & 0.00e+0 & 0.00e+0 & 0.1 & 1 & 100\% & 11\% \\\hline

can be hardAn over-engineered table; avoid all this if possible

Use \begin{table*}...\end{table*} to make a table span columns in two-column papers.

excel2latexVBA add-in for converting Excel data to LaTeX tables

Page 11: James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief

\begin{tabular}{ }

11

lcr @{sep} p{width}

left rightcentre Text in this cell will be wrapped and justified.

width

@{sep} replaces default gap with sep, which can be text or spaces.

In p{width}, width must be unit of distance, including mm, cm, m, in, or even printing measures like ‘ex’ and ‘em’.

booktabsbetter spacing of lines around table contents

colortblcontrol cell background colour & line colour

And for styling:

Page 12: James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief

12

More tricks with tables

multirowsupport multi-row cells

longtableallows tables to split over pages

lscaperotate part of document 90

rotatingrotate part of documentby any angle

Tabl

e 1.

Thi

s ca

ptio

n sh

ould

not

be

legi

ble

Tabl

e 2.

Now

this

is ju

st sil

ly

Page 13: James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief

13

paper2.tex

Captions and labels

return

Make labels (i.e., \label) in papers unique across papers. This will make it easier when creating chapters from those papers.

\caption[Short caption for list of tables]{Long, descriptive caption to appear with table}

Works with \section commands, too

paper1.tex

thesis.tex

List of Tables

Table 1. BriefTable 2. SuccinctTable 3. Laconic

Table 1. Described in full, with lots of explanation.

v

Page 14: James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief

14

Use vector graphics formats where possible; will print better and (generally) be smaller

Graphics creation

Inkscape is one optionAdd textext plug-in to include LaTeX generated content

Gnuplot can produce a variety of high quality charts and graphs

PDFs are suitable when using pdfLaTeX

Page 15: James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief

15

Figures

return

subfigseparate captions for sub-figures

graphicxsupport for loading image files into document

If you really want separate figures side by side then use the minipage environment

Figure 1. Shared caption

\begin{figure}\centering\subfloat[Box]{ \includegraphics{subfigure1} \label{fig:subfig1}}\subfloat[Arrow]{ \includegraphics{subfigure2} \label{fig:subfig2}}\label{fig:bothfigures}\caption{Shared caption for \subref{fig:subfig1} and \subref{fig:subfig2}}\end{figure}

(a) Box (b) Arrow

for (a) and (b)

figure* to span columns

Page 16: James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief

Algorithms and code

16

return

algorithmfloating algorithm environment like figure or table

algorithmicformatting algorithms, keywords, etc.

listingssyntax highlighting for different languages

xcolordefining and using colour

Algorithm 1. Collatzn := from userwhile n 1 do if n is even then n := n / 2 else n := n * 3 + 1 endend

+ +

program collatz;var n : integer;begin n := Readln; while n <> 1 do begin if not odd(n) then n := n / 2 else n := n * 3 + 1; end;end;

Page 17: James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief

17

Positioning floats – Error 404

• The content here was going to be so low-level that it’s been left out. It would have included tricks like– Moving where table of figure appears in TeX

source (consider a separate file and \input to make this easier)

– Forcing the float onto its own page (with other floats) with [p] placement specifier

– Using \clearfloatsreturn

Page 18: James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief

18

BibTeX

return

Use a tool to maintain your BibTeX databases. For example, JabRef or BibDesk (on Mac)

natbibalternative cite commands

Unless you are an expert in the programming language Forth, don’t edit BibTeX style files (.bst); look for one that suits your needs

According to Smith et al. (1990), that is Smith, Jones, and Johns (1990), or even (Smith et al. 1990).

According to \citet{smi90}, that is \citet*{jon90}, or even \citep{jon90}.

Page 19: James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief

19

Basic stylingfancyhdrfine-grained control over header and footer content

fullpage or geometryeasy smaller margins orcontrol over margins

savetreesreduce space usage; but doesn’t look as nice

Page 20: James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief

20

\tiny

\scriptsize\footnotesize\small\normalsize\large\Large

\LARGE\huge

\Huge

Standard LaTeX font sizes are not always sufficient

More styling

flushendbalance columns at the end of a paper

relsizescale fonts with finer control; useful in tables.

return

Balancing Columns

Page 21: James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief

21

Large documents like your thesis\documentclass[a4paper]{book}

% packages etc.

\input{macros}

\begin{document}

\frontmatter

% title page, TOC, etc.

\mainmatter

\includeonly{chapter 1}

\include{chapter1}

\include{chapter2}

...

\appendix

\include{appendix1}

...

\backmatter

%bibliography etc.

Note: This is not a complete skeleton document

.bib

.sty

macros.tex

appendix1.tex

chapter1.tex

chapter2.tex

Your abbreviations and other handy utilities

Page 22: James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief

22

Useful packages

xrinter-document cross-references; useful if compiling chapters separately

With some command trickery you can compile chapters separately or as part of whole document. See appendix.

hyperrefhyperlinks in PDFs

cleverefgenerates all text for cross-references, not just number

setspaceset line spread as needed

Chapter 1Some Illustrative Text

This chapter is only here to illustrate that the cleveref package can generate the entire text for a cross-reference such as in Section 1. cleverref must be loaded last.

Similarly, hyperref makes cross-reference numbers hyperlinks, as in Section 2 on page 3.

The xr package allows for inter-document cross-references (see Chapter 2), if those documents are compiled separately.

See the source

anuthesisANU-specific styling

Page 23: James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief

24

Other uses for LaTeX

• In PowerPoint: ‘TeX4PPT’– Older, but easy install

http://users.ecs.soton.ac.uk/srg/softwaretools/presentation/TeX4PPT/– Newer, slightly fiddly install, works better

https://sites.google.com/site/tex4ppt/

• Instead of PowerPoint:– Packages like beamer

Page 24: James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief

25

Further reading and seeking help

The Not So Short Introduction to LATEX2ε (1995–2011) by Tobi Oetiker & contributorshttp://tobi.oetiker.ch/lshort/

Math into Latex (2000) by George GrätzerMany free copies available on the web

TeX Stack Exchange http://tex.stackexchange.com/

CTAN for package documentationhttp://www.ctan.org

www

www

Page 25: James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief

26

Things to look out for in the future

• New front ends to LaTeX with native support for Unicode (so no more \"a for ä) and other features:

• XeTeX• LuaTeX

Appendix