LaTeX Tutorial Syed Jan09

Embed Size (px)

Citation preview

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    1/42

    LaTeX tutorial

    Syed Shazli

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    2/42

    Most of the material taken fromMonash UniversityOnline material available from Googling

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    3/42

    Preface

    LaTeX is a typesetting system (not a wordro!essor"#$t is most s%ited to rod%!ing s!ientifi! andmathemati!al do!%ments of highty ogra hi!al &%ality#

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    4/42

    Why not MS Word?

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    5/42

    Advantages and

    Disadvantages (1) 'dvantages of LaTeX over )S$ )G*

    rofessionally !rafted layouts are availablethe typesetting of mathematical formulae is s% orted ina !onvenient way%sers need only to learn a few simple commands + whi!hs e!ify the logi!al str%!t%re of a do!%ment#

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    6/42

    Advantages and

    Disadvantages ( ) 'dvantages of LaTeX over )S$ )G*complex structures s%!h as footnotes+ referen!es+table of !ontents+ and bibliogra hies !an be generatedeasily

    for many ty ogra hi!al tasks not dire!tly s% orted bybasi! LaTeX+ there e,ist free add-on packagesLaTeX is highly portable and free

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    7/42

    Advantages and

    Disadvantages (!)LaTeX also has some disadvantages*hat yo% see is not what yo% get#$s this really a disadvantage- hy are yo% thinking abo%tlayo%t instead of !ontent-

    The design of a whole new layo%t is diffi!%lt and takesa lot of time#

    Tem lates hel yo% here

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    8/42

    LaTeX "n#ut $iles

    The in %t for LaTeX is a lain 'S.$$ te,t file#)o% !an !reate it with any te,t editor#$t !ontains

    the te,t of the do!%ment!ommands whi!h tell LaTeX how to ty eset the te,t#

    S a!es S e!ial .hara!ters

    LaTeX .ommands .omments

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    9/42

    S#aces

    hites a!e !hara!ters (e#g# blank+ tab+ single linebreak" are treated %niformly as /s a!e0 byLaTeX#

    Several !onse!%tive whites a!e !hara!ters aretreated as one /s a!e0#

    'n em ty line between two lines of te,tdefines the end of a aragra h#

    Several em ty lines are treated in the same wayas one em ty line#It does not matter whether youenter one of several spaces after aword.An empty line starts a newparagraph.

    $t does not matter whether yo% enter one orseveral s a!es after a word#

    'n em ty line starts a new aragra h#

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    10/42

    S#aces

    It does notmatter whetheryou enter one ofseveral spacesafter a word.An empty linestarts a new

    paragraph.

    $t does not matterwhether yo% enter oneor several s a!esafter a word#

    'n em ty line starts anew aragra h#

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    11/42

    S#ecial %haracters

    The following symbols are reserved!hara!ters+ thathave a s e!ial meaning in LaTeX

    1 2 3 4 5 6 7 8 9 :

    Some of these !hara!ters !an be %sed inyo%r do!%ments by adding a refi, ba!kslash(es!a e !hara!ter"*

    $ & % # _ { } $ & % # _ { }

    The other symbols (and many more;" !an berinted with s e!ial !ommands in

    mathemati!al form%lae#

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    12/42

    LaTeX %o&&ands (1)

    LaTeX !ommands are !ase sensitive andtake one of two formats* They start with a ba!kslash : and have a name!onsisting only of letters#

    They !onsist of a ba!kslash and e,a!tly one s e!ial!hara!ter#

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    13/42

    LaTeX %o&&ands ( )

    I read that Knuth divides people working with TeXinto TeXnicians andTeXperts. Today is March

    25th, 2004.

    I read that !nuthdivides peoplewor"ing with

    e {} intoe {}nicians ande perts. oday

    is today.

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    14/42

    LaTeX %o&&ands (!)Some !ommands take a arameter whi!h has to begiven between !%rly bra!es 6 7 after the !ommandname#Some !ommands s% ort o tional arameters

    whi!h are added after the !ommand name ins&%are bra!kets < =#The ne,t e,am le %ses some LaTeX !ommands#

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    15/42

    LaTeX %o&&ands (')

    his is emphasized te t.

    lease start a new lineright here'

    han" you'

    This is:em h6em hasized7 te,t#

    >lease start a new lineright here;:linebreakThank yo%;

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    16/42

    %o&&ents

    hen LaTeX en!o%nters a%

    !hara!ter whilero!essing an in %t file+ it ignores the rest ofthe resent line#This is %sef%l for adding notes to the in %tfile+ whi!h will not show % in the rintedversion#

    his te t isprocessed.

    This te,t is ro!essed# 3 ' !omment

    isn?t

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    17/42

    "n#ut $ile Structure (1)hen LaTeX@e ro!esses an in %t file it e, e!ts it

    to follow a !ertain str%!t%re# Avery in %t file startswith the !ommand*

    documentclass{...}

    This s e!ifies what sort of do!%ment yo% intend to write(arti!le+ letter+ book+ !ssethesis+ et!#"

    'fter that+ yo% !an in!l%de global style !ommands oryo% !an load a!kages whi!h add new feat%res to

    the LaTeX system# To load a a!kage yo% %se the!ommand*

    usepac"age{...}

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    18/42

    "n#ut $ile Structure ( )hen all the set% work is done+ yo% start the

    body of the te,t with the !ommand*

    (egin{document} Bow yo% enter the te,t mi,ed with some %sef%lLaTeX !ommands#

    't the end of the do!%ment yo% %se the

    end{document}

    !ommand+ whi!h tells LaTeX to finish# 'nythingwhi!h follows this !ommand will be ignored byLaTeX

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    19/42

    Parts of a LaTeX Docu&entdocu&entclass

    Cirst line of all LaTeX do!%ments s e!ifiesthe 6ty e7 of the do!%ment and the

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    20/42

    A Sile LaTeX Docu&ent

    :do!%ment!lass 6arti!le 7

    :begin 6do!%ment 7This is some sam le te,t#:end 6do!%ment 7

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    21/42

    A &ore realistic LaTeX *ledocumentclass)a*paper+,,pt-{article}usepac"age{late sym}author{ ./ ha0li}title{1ependa(le 2anocomputing 3a(}(egin{document}

    ma"etitleta(leofcontentssection{Introduction}

    4ere (egins my first article ldotssection{5onclusions}ldots{} and here it ends.end{document}

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    22/42

    Sections \section 6Se!tion Title 7

    \subsection 6Title7

    \subsubsection 6Title7

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    23/42

    $ont si+e:tiny :s!ri tsize :footnotesize :small :normalsize :large :Large

    :L'DGA :h%ge:E%ge

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    24/42

    Page StylesLaTeX s% orts three redefined headerFfooter!ombinations# These are known as age styles#The style arameter of the \pagestyle{style} !ommand defines whi!h one to %se*

    plain rints the age n%mbers on the bottom of the agein the middle of the footer (defa%lt age style"headings rints the !%rrent !ha ter heading and the agen%mber on ea!h age# Cooter is em tyempty both header and footer em ty

    More elaborate headers and footers !an be !reated%sing the fancyheadings a!kage

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    25/42

    o find the s6uare ofthe hypotenuse+ add a

    s6uared to ( s6uaredto find c s6uared+e.g. .It7s as easy as that'

    Ty#esetting Mathe&aticsLaTeX has a s e!ial mode for ty esettingmathemati!s+ !alled /math mode0#

    ithin a aragra h+ math mode is enteredbetween $ !hara!ters+ or by %sing the\begin{math} and \end{math} !ommands

    To find the s&%are ofthe hy oten%se+ add a

    s&%ared to b s&%ared tofind ! s&%ared+ e#g#1a9@ H b9@ I !9@1# $t?sas easy as that;

    222 cba =+

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    26/42

    Ty#esetting Mathe&aticsreek !ymbols

    \alpha" \beta" \gamma!uperscript" !ubscript

    x#y x$y x$y#%Calculus

    \int$\infty \int{\int}

    \frac{ \partial u}{ \partial x}

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    27/42

    Ty#esetting Mathe&atics

    x ' \frac {-b \pm \s(rt{ b#)-*ac } } {)a }

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    28/42

    Ty#esetting Mathe&atics$n a resear!h a er or thesis+ yo% will often want to n%mbere&%ations and refer to them in the te,tThis is done %sing the e6uation environment+ and the!ommands la(el and ref

    note that la(el and ref are used with !igures and ta"les too#

    $ it is clear that

    > 0. (1)

    %ro& '(uation ) it !ollows that...

    ldots it is clear

    that(egin{e6uation}epsilon 8 9.la(el{e6:eps}end{e6uation}

    ;rom

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    29/42

    Ty#esetting Mathe&aticsMatri!es are rod%!ed %sing the :te,tbf6array7environment# A,am le*

    The \emph{characteristic polynomial} $\chi(\lambda)$ of the$3 \times 3$~matrix\[ \left( \begin{array}{ccc}a & b & c \\d & e & f \\g & h & i \end{array} \right)\is gi!en by the form"la\[ \chi(\lambda) # \left \begin{array}{ccc}\lambda % a & %b & %c \\%d & \lambda % e & %f \\%g & %h & \lambda % i \end{array} \right \

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    30/42

    "ncluding ,ra#hicsLaTeX@e in!l%des a standard a!kage forin!l%ding PostScript gra hi!s in yo%rdo!%ment# Load it %sing

    usepac"age{graphics}

    ' fig%re !an be in!l%ded %sing+ for e,am le+

    (egin{figure})ht-(egin{center}

    includegraphics)width=,*9mm-{mypic.ps}end{center}caption{An e ample of a figure.}la(el{fig:e ample}end{figure}

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    31/42

    $igures and Ta-lesCig%res 2 Tables !annot be broken between

    ages

    They are / floated 0

    \begin 6fig%re7 \includegraphics 6sam le7

    \caption 6' sam le fig%re#7 \end 6fig%re7

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    32/42

    .ol%mns(egin{ta(ular}{>?>?>}end{ta(ular}

    Dows& S lit te,t into !ol%mns

    And a rowhline Jraw line %nder row

    e#g#,@ ,@ & *.99 hline

    Two *olu&ns

    l + auto&atically ad ustsi-e, le!t usti!y

    r + auto&atically ad ustsi-e, right usti!y

    p + set si-e

    e.g p 4./c&c + centre te1t

    Ta-ular

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    33/42

    ./ale of ta-le(egin{ta(ular}{>l>r>c>} hline

    1ate & rice & i0e hlineBesterday & C & Dig hline

    oday & & mall hlineend{ta(ular}

    Date Price Size

    Yesterday 5 Big

    Today 3 Small

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    34/42

    %ross0referencing \label 6marker 7 \ref 6marker 7 \pageref 6marker 7

    A,am le* \section 6$ntrod%!tion7 \label 6intro7

    +

    As mentioned in section \ref {intro} in page pageref {intro}

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    35/42

    i-liogra#hies 'rti!les !an be referred to in the te,t %singthe :!ite !ommandThe details of the !ited arti!les are stored inKibTeX format+ in a /#bib0 file#KibTeX resolves the !itations in the LaTeX fileand generates the re&%ired bibliogra hy

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    36/42

    i-liogra#hies

    Dy far the mostcommonly used featureis color Ee.g.),+@+ -F+ usuallycomputed in a colourspace thought to (eGperceptuallyaccurateH Ee.g. 4) - or 5I< )*-.

    Ky far the most!ommonly %sed feat%reis !olor (e#g#::!ite6BKA N+ aP Q+Sm. Qa7"+ %s%ally!om %ted in a !olors a!e tho%ght to beRR er!e t%ally a!!%rate(e#g# ESP

    :!ite6Sm. Qa7 or .$A:!ite6STL 7"#

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    37/42

    i-liogra#hiesA,am le KibTeX entries from a #bib file*

    J(oo"{AhK,LMC+author = {2. Ahmed and !. Kao}+title = {Nrthogonal transforms for digital signal

    processing}+pu(lisher = { pringerO erlag}+year = {,LMC}+address = {2ew Bor"}+

    }

    Jinproceedings{Aus,LPL+author = {Qames Austin and A. hantom and

    Also hantom}+

    title = {4igh peed Invariant Kecognition RsingAdaptive 2eural 2etwor"s}+(oo"title = {I

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    38/42

    2unning LaTeXThe sim lest way to r%n LaTeX on a so%r!edo!%ment is to do so at the UB$X !ommandline*

    These will be*

    8late test.te

    test.au 4 the a%,iliary file that LaTeX will %se in s%bse&%entasses to resolve referen!es to fig%res+ tables+ !itations et!#

    test.log 4 a log file that !ontains information abo%t the LaTeXr%ntest.dvi 4 the JePi!e $nde endent o%t %t file# This is thety eset do!%ment+ ready for !onversion to osts!ri t or other rintableformats

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    39/42

    2unning LaTeXe !an view the do!%ment we have !reated

    %sing a JP$ viewer# The most !ommon one%nder UB$X is xd!i # Ty e

    'xd!i testto see the ty eset do!%ment$t is im ortant to realise that LaTeXsometimes needs to be r%n several times toresolve all referen!es#

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    40/42

    our 3ate1 %ile our i"te1 %ile

    3ate1 co&pile 1

    i"te1 co&pile 12

    3ate1 co&pile 1

    our 6ostscript %ile

    dvips co&pile 1)Jevi!e inde endento%t %t #dvi

    (a te,t file"

    %reating Late/ $iles

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    41/42

    3ut#ut $or&ats ,d i Jevi!e $nde endent ,ps >ost S!ri t ,pdf >JC

    ,rtf Di!h Te,t Cormat ,html ETML ,xml XML

  • 7/25/2019 LaTeX Tutorial Syed Jan09

    42/42