19
Intro to LaTeX WING meeting 12 Jan 2007

Intro to LaTeX WING meeting 12 Jan 2007. 2 What’s LaTeX? >An alternative to using MS Word for writing reports and papers >Our target today: HYP Thesis

Embed Size (px)

Citation preview

Page 1: Intro to LaTeX WING meeting 12 Jan 2007. 2 What’s LaTeX? >An alternative to using MS Word for writing reports and papers >Our target today: HYP Thesis

Intro to LaTeXWING meeting 12 Jan 2007

Page 2: Intro to LaTeX WING meeting 12 Jan 2007. 2 What’s LaTeX? >An alternative to using MS Word for writing reports and papers >Our target today: HYP Thesis

2

What’s LaTeX?

> An alternative to using MS Word for writing reports and papers

> Our target today:  HYP Thesis

  ACM Conference Submissions

  PhD Thesis

> Best Practice Tools

Page 3: Intro to LaTeX WING meeting 12 Jan 2007. 2 What’s LaTeX? >An alternative to using MS Word for writing reports and papers >Our target today: HYP Thesis

3

Why LaTeX?

> Plain Text with Markup> Forces you to concentrate on writing> Takes care of math, figure positioning,

references, and tables of contents quite well.> Free!

> Why not LaTeX?  Steep learning curve

  Not WYSIWYG (even with 3rd party tools)

  Needs compilation

  Ugly tables and Figure inclusion is hard

> Conclusion: use if you have time to learn

Page 4: Intro to LaTeX WING meeting 12 Jan 2007. 2 What’s LaTeX? >An alternative to using MS Word for writing reports and papers >Our target today: HYP Thesis

4

Example of LaTeX document

\documentclass{article}

\title{Simple Example}

\author{Andrei Gurtov}

\date{March 2000}

\begin{document}

\maketitle

Hello world!

\end{document}

Page 5: Intro to LaTeX WING meeting 12 Jan 2007. 2 What’s LaTeX? >An alternative to using MS Word for writing reports and papers >Our target today: HYP Thesis

5

Tabular> Columns

  \begin{tabular}{|…|…|}  \end{tabular}

> Rows  & - Split text into columns  \\ - End a row  \hline - Draw line under row

  e.g. 123123 & 34.00\\ \hline

l = automatically adjust size, left justifyr = automatically adjust size, right justifyp = set size e.g p{4.7cm}c = centre text

Two Columns

Page 6: Intro to LaTeX WING meeting 12 Jan 2007. 2 What’s LaTeX? >An alternative to using MS Word for writing reports and papers >Our target today: HYP Thesis

6

Example of table

\begin{tabular}{|l|r|c|} \hline

Date & Price & Size \\ \hline

Yesterday & 5 & big \\ \hline

Today & 3 & small \\ \hline

\end{tabular}

Date Price Size

Yesterday 5 Big

Today 3 Small

Page 7: Intro to LaTeX WING meeting 12 Jan 2007. 2 What’s LaTeX? >An alternative to using MS Word for writing reports and papers >Our target today: HYP Thesis

7

Floating Objects

> Floating objects can stop splitting of tables and images over pages.\begin{figure}[options]

\end{figure}

\begin{table}[options]

\end{table}

> They will now appear in the   List of Figures (LOF) and

  List of Tables (LOT).

Options (recommendations)h = place table heret = place at top of pageb = place at bottom of page

Page 8: Intro to LaTeX WING meeting 12 Jan 2007. 2 What’s LaTeX? >An alternative to using MS Word for writing reports and papers >Our target today: HYP Thesis

8

Example of floating figure

> \begin{figure}[ht]> \centering\epsfig{file=uni.ps, width=5cm}> \caption{University of Helsinki}> \label{uni}> \end{figure}

Figure~\ref{uni} shows...

Width and height modifiers

Page 9: Intro to LaTeX WING meeting 12 Jan 2007. 2 What’s LaTeX? >An alternative to using MS Word for writing reports and papers >Our target today: HYP Thesis

9

Some Math

\begin{center}{\large$$ y=\frac{a^3+2c_{x}}{1+\sqrt{b_{x}}}

$$ \\\vspace{0.2in}$$ Q=\sum_{i=1}^{j}\int_{\mu}^{\

infty}f(x_{j})dx $$ \\\vspace{0.2in}$$ \Psi = \oint_{- \infty}^{\infty}f_{xy}({\

frac{\partialQx}{\partial Qy}})^{\Im_{\pi}^ \prime} $

$ \\ }

Page 10: Intro to LaTeX WING meeting 12 Jan 2007. 2 What’s LaTeX? >An alternative to using MS Word for writing reports and papers >Our target today: HYP Thesis

10

Local .sty and .cls files

> These are the files that control the formatting of the final file (look&feel)  LaTeX uses .sty (style files)  LaTeX2E uses .cls (class files)

> For HYP reports use Wei Tsang’s page  Google “latex ooiwt” or “latex nus soc”

> For Ph.D. thesis use Hang’s template  www.cuihang.com/software/thesis_template.zip   Or WING cvs sg/edu/nus/comp/hang/thesis_template

> For papers, start with the ACM template  Google “acm latex template”, use alternate tighter

style

Page 11: Intro to LaTeX WING meeting 12 Jan 2007. 2 What’s LaTeX? >An alternative to using MS Word for writing reports and papers >Our target today: HYP Thesis

11

Trivial to do

> Create a table of contents> Create a table of figures> Create the bibliography

  Only records that were referenced will be included

  This means you can keep all of the references you will ever use in one BibTex file.

Page 12: Intro to LaTeX WING meeting 12 Jan 2007. 2 What’s LaTeX? >An alternative to using MS Word for writing reports and papers >Our target today: HYP Thesis

12

Bibliography using BibTex

> Bibliography information is stored in a*.bib file, in BibTex format.

> Include chicago package (at top)  \usepackage{chicago}

> Set referencing style (at end)  \bibliographystyle{chicago}

> Create reference section by  \bibliography{bibfile with no extension}

Page 13: Intro to LaTeX WING meeting 12 Jan 2007. 2 What’s LaTeX? >An alternative to using MS Word for writing reports and papers >Our target today: HYP Thesis

13

Bibliography using Bibtex

@book{Come95,author=“D. E. Comer”,title={Internetworking with TCP/IP:

Principles, Protocols and Architecture},publisher=“Prentice-Hall”,year=1995,volume=1,edition=“Third”}

Page 14: Intro to LaTeX WING meeting 12 Jan 2007. 2 What’s LaTeX? >An alternative to using MS Word for writing reports and papers >Our target today: HYP Thesis

14

Bibliography contd.

> Citing references in text  \cite{cuc98} = (Cuce 1998)  \citeN{cru98} = Crud (1998)  \shortcite{tom98} = (Tom, et. al. 1998)

> Creating Bibtex Files  Use Emacs with extensions.

  or copy Bibtex entries from bibliography database.

  ACM Portal has option to get BibTex reference

Page 15: Intro to LaTeX WING meeting 12 Jan 2007. 2 What’s LaTeX? >An alternative to using MS Word for writing reports and papers >Our target today: HYP Thesis

15

Problems

> Often LaTeX will fail with an error.

> If it has a question mark for you, type “x” and press enter.

> This will quit LaTeX.

> When LaTeX dies like this, it is almost always because you screwed up.

Page 16: Intro to LaTeX WING meeting 12 Jan 2007. 2 What’s LaTeX? >An alternative to using MS Word for writing reports and papers >Our target today: HYP Thesis

16

How to solve problems

> Look at the error LaTeX gave you.

> It will have a line number which will help you find the error.

> Common mistakes:  Mismatched \begin{}/\end{} blocks  Mismatched {/}  Mismatched $, $$, or \(\) or \[\]  Misspelled keywords

> Sometimes lines are too long. This isn’t fatal but looks bad. LaTeX outputs a warning with a line number so you can fix it.

Page 17: Intro to LaTeX WING meeting 12 Jan 2007. 2 What’s LaTeX? >An alternative to using MS Word for writing reports and papers >Our target today: HYP Thesis

17

Best Practice Tools

> make to create your pdf file> Use another program to create eps or pdf

figures for inclusion.  PowerPoint, or xfig

  Use graphicx or epsfig package for eps figures

  You can import raster graphics (jpg) but this is trickier; make sure resolution is correct

> Use GhostView to see revisions  Can read PDF, not as slow or feature heavy as

Acrobat Reader

  Handles re-opens well

> Need to count words?   Use my texWordCount.pl script, from my software

page.

Page 18: Intro to LaTeX WING meeting 12 Jan 2007. 2 What’s LaTeX? >An alternative to using MS Word for writing reports and papers >Our target today: HYP Thesis

18

General Best Practices

> Check in your revisions very often to get CVS to backup your stuff  You may need to refer to your old files

  Do comment your revisions

  Use in file CVS $Id$ and $Log$ to see revision history

> Use specific comments  Comments start with % but don’t show

  Use % BUG: to tell me what to correct, I will do the same

  Use % GUB: to tell me what’s fixed; I will then delete the line if I agree

> Use inline notes {\em BUG: xxx }   If you need me to see a thing wrt to the actual file.

Page 19: Intro to LaTeX WING meeting 12 Jan 2007. 2 What’s LaTeX? >An alternative to using MS Word for writing reports and papers >Our target today: HYP Thesis

19

Need help?

> Use the web; learn by example> One in particular:

Hypertext help for LaTeX  http://www.comp.nus.edu.sg/~kanmy/latex (local)