Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief."— Presentation transcript:

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

2 How LaTeX works (logical structure) 2 typesettingdocument structure Your.tex document pdfLaTeX frontend XeTeX frontend... frontend

3 Boxes: How TeX typesets 3 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

4 ... How LaTeX ‘works’.cls.tex.aux.toc.bib.out.eps,.pdf latex pdflatex xelatex etc..sty.bbl Lots and lots of files 4

5 LaTeX processing steps 5.tex.aux.bib.bbl >pdflatex doc.tex >bibtex doc >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

6 Workflows 6 Emacs (with AUCTeX) Lyx TeXnicCenter ( only) TeXlipse TeXShop (in MacTeX on ) Vim (with Vim-LaTeX) Git SVN Use source control Use an editor with syntax highlighting and code completion svn-multi to include SVN version data in drafts It’s code, so when things don’t work, debug \iffalse (or %comment) Create a \comment{...} command

7 Working with others 7 todonotes marginal notes and figure placeholders... \input{james} \input{mark} \input{steve}... Option 1: Break up the document intro.tex method.tex results.tex Option 2: Agree to work on different parts (and let source control handle merging) Margin notes using any convenient package doc.tex james.tex mark.tex steve.tex doc.tex

8 Arrangingfloats Bibliographies Algorithms & code listings Tables Graphics creation & figures Math Inside your document 8 Title 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 := 1 while true add 1 to COBOL end 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 1Col 2Col 3 — — — Table 1. Has a caption Skip over these Style

9 Math 9 return Many LaTeX editors provide menus of symbols ntheorem predefined theorem & proof environments amsmath, amsfonts, amssymb theorems, better math fonts & symbols mathtools fixes some things in amsmath; adds new functionality Early on, have a cheat sheet handy

10 Tables Use an editor for complex tables e.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 hard An over-engineered table; avoid all this if possible Use \begin{table*}...\end{table*} to make a table span columns in two-column papers. excel2latex VBA add-in for converting Excel data to LaTeX tables

11 \begin{tabular}{ } 11 lcr@{sep}p{width} leftrightcentreText 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’. booktabs better spacing of lines around table contents colortbl control cell background colour & line colour And for styling:

12 More tricks with tables 12 multirow support multi-row cells longtable allows tables to split over pages lscape rotate part of document 90  rotating rotate part of document by any angle Table 1. This caption should not be legible Table 2. Now this is just silly

13 paper2.tex Captions and labels 13 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. Brief Table 2. Succinct Table 3. Laconic Table 1. Described in full, with lots of explanation. v

14 Use vector graphics formats where possible; will print better and (generally) be smaller Graphics creation 14 Create graphics in multiple formats if possible (EPS, PDF, JPG) Inkscape is one option Add 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

15 Figures 15 return subfig separate captions for sub-figures graphicx support 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

16 Algorithms and code 16 return algorithm floating algorithm environment like figure or table algorithmic formatting algorithms, keywords, etc. listings syntax highlighting for different languages xcolor defining and using colour Algorithm 1. Collatz n := from user while n  1 do if n is even then n := n / 2 else n := n * 3 + 1 end ++ 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;

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 \clearfloats 17 return

18 BibTeX 18 return Use a tool to maintain your BibTeX databases. For example, JabRef or BibDesk (on Mac) natbib alternative 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 needsForth 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}.

19 Basic styling 19 fancyhdr fine-grained control over header and footer content fullpage or geometry easy smaller margins or control over margins savetrees reduce space usage; but doesn’t look as nice

20 \tiny \scriptsize \footnotesize \small \normalsize \large \Large \LARGE \huge \Huge Standard LaTeX font sizes are not always sufficient More styling 20 flushend balance columns at the end of a paper relsize scale fonts with finer control; useful in tables. return Balancing Columns

21 Large documents 21 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.texchapter1.texchapter2.tex Your abbreviations and other handy utilities

22 Useful packages 22 xr inter-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.appendix hyperref hyperlinks in PDFs cleveref generates all text for cross- references, not just number setspace set line spread as needed Chapter 1 Some 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 anuthesis ANU-specific styling

23 23 \chapter{Some Illustrative Text} This chapter is only here to illustrate that the \textsf{cleveref} package can generate the entire text for a cross-reference such as in \cref{sec:sec1}. \textsf{cleverref} must be loaded last. Similarly, \textsf{hyperref} makes cross-reference numbers hyperlinks, as in \cref{sec:sec2} on \cpageref{sec:sec2}. The \textsf{xr} package allows for inter-document cross-references (see Chapter~\ref{ch:chap2}), if those documents are compiled separately. Go back

24 Other uses for LaTeX In PowerPoint: ‘TeX4PPT’ –Older, but easy install http://users.ecs.soton.ac.uk/srg/softwaretools/presentation/TeX4PPT/ http://users.ecs.soton.ac.uk/srg/softwaretools/presentation/TeX4PPT/ –Newer, slightly fiddly install, works better https://sites.google.com/site/tex4ppt/ https://sites.google.com/site/tex4ppt/ Instead of PowerPoint: –Packages like beamer 24

25 Further reading and seeking help The Not So Short Introduction to LATEX2ε (1995–2011) by Tobi Oetiker & contributors http://tobi.oetiker.ch/lshort/ http://tobi.oetiker.ch/lshort/ Math into Latex (2000) by George Grätzer Many free copies available on the web TeX Stack Exchange http://tex.stackexchange.com/ http://tex.stackexchange.com/ CTAN for package documentation http://www.ctan.org http://www.ctan.org 25 www

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 26 Appendix

27 To support separate compilation of chapters In thesis.tex: \newcommand{\isEmbedded}{true} Chapters then have the following structure: \ifx\isEmbedded\undefined... \documentclass{class} \input{preamble} %preamble.tex contains \usepackage commands etc. \setcounter{chapter}{0} %chapter number – 1 \externaldocument{other_chapter_referenced_here} %xr package required \begin{document} \else \fi % Chapter contents \ifx\isEmbedded\undefined \input{bibliography} \end{document} \else \fi Appendix Go back 27

28 Summary of Creative Commons Licence You are free to: Distribute copies of this work Adapt the work Provided that you: Attribute the work to James Montgomery Do not use it for commercial purposes If you alter or build upon it and then share it, it must be shared under a similar licence 28 Appendix Return to title slide


Download ppt "James Montgomery with contributions from many other users Research School of Computer Science Australian National University Tips and Tricks for View brief."

Similar presentations


Ads by Google