Learn Latex7

download Learn Latex7

of 8

Transcript of Learn Latex7

  • 8/3/2019 Learn Latex7

    1/8

    How to learn LaTeX in 7 minutes?

    Ernst Witand Simon N. Wood

    Department of Statistics, University of Glasgow

    Glasgow G12 8QW, U.K.

    December 28, 2010

    Abstract

    This paper will teach you how to use LATEXin some minutes. Infact, all you have to know is how to load this file, called learn-latex.texinto WinEdt and know that you should press the LATEXbutton to cre-ate the nice looking file, the Bib button to include the bibliographicreferences in the nice looking file (that you have to repeat this processtwo times before the file learns the appropriate names) and the DVIbutton to show you the nice looking file. The DVIPDF button gen-erates a PDF file, which you can share with your collaborators or withjournals.

    Everything else you have to learn about LATE

    Xyou should simplysteal from this document.

    Make sure that you also save the two additional files in your di-rectory: the first file is extendibility.bib, the bibliography file, andthe second file is alleles-nonselves-rss.ps, the postscript file thatcontains a figure.

    1 Introduction

    LATEXis a rather flexible mathematical typesetting package. Various fontsand sizes of font are available. For example typewriter, italic, emphasised,

    san serif, bold as well as the default roman. Combinations of some arepossible emphasised san serif, for example. LATEXis very good at dealing withequations, only uses plain text, so its easy to email and doesnt producemysterious reformatings of your document every time you use a differentversion.

    [email protected]@stats.gla.ac.uk

    1

  • 8/3/2019 Learn Latex7

    2/8

    1.1 document classes

    The way your document will look and be structured depends on thedocumentclass command at the top of the file. Useful classes are: letter,article, for reports and journal articles and book for theses and books.

    1.2 sections

    Articles are usually structured into sections, and books into chapters andchapter sections. Sections can be cross referenced, if you \label them. Forexample the Introduction is section 1 in this document. Sub-sections arepossible

    1.2.1 sub-sub-sections are also possible

    Sometimes you also want a section without a number . . .

    Like this

    which used the subsection* command.

    1.3 Spaces, gaps, pagebreaks, etc.

    Sometimes you want to over-ride the default formatting in various ways.Here are a few common examples.

    If you leave a blank line between two lines of text LATEXassumes thatyou want a new paragraph and indents accordingly.Sometimes you dont want this indentation and the \noindent command isuseful.

    Perhaps you want more space between lines.

    \bigskip will do this for you in a manner that takes account of the fontsize in use. But sometimes you want more control - a 0.6cm vertical space,for example . . .

    or even a horizontal space.Sometimes you may want to

    break a line in a different place to the default in which case use \\ to inserta line break.

    Sometimes you just want the wretched page to end right now

    2

  • 8/3/2019 Learn Latex7

    3/8

    \pagebreak does this, although sometimes this means that LATEXstretches

    out everything above the page break out in an ugly way, in which case\vfil\eject is better.

    2 Equations

    The real beauty of LATEXis equations. For inline equations like, (x1, x2) =2x1+2x2, simply insert the instructions defining the equation between single$ signs. If you want a display equation without a number put the instructionsbetween $$s like this:

    X =

    cos + sin 0 0 . . .

    cos sin 0 . . .cos 0 sin . . .

    ......

    .... . .

    0 cos + sin 0 . . .0 cos sin . . ....

    ......

    . . .

    If you want an equation to have a number then you need to use begin{equation}and \end{equation} for example

    = Mx dx (1)Numbered equations like equation (1) can be referenced using \ref. Notethat bold Greek letters, like are only available if you have \usepackage{bm}near the top of your document.

    Multi-line equations (without numbering) are produced like this:

    (af1 + bf2) (x) := af1(x) + bf2(x)

    = axt1 + bxt2

    = xt(a1 + b2).

    or with numbering like this:

    (n, T) = B(n, T) (n, T) (2)

    = { | = X , RnT} { | ii 0, ij = ji R, i = j}

    Often you may want something like this:

    f(xi) =

    (+ 1)xi 0 < xi < 10 otherwise

    the large { is achieved using the bracketing commands \left and \rightalong with the null bracket symbol ..

    3

  • 8/3/2019 Learn Latex7

    4/8

    3 Documentation

    At this point you may be feeling the need for a less random source of in-formation. If you are going to use LATEXto write your thesis then get holdof:

    Kopka, H. and P.W. Daly A guide to LATEX Addison Wesley.

    Its comprehensive and excellent.Within WinEdt try Help>LaTeX2e from the menues.

    4 Figures

    You will need to include figures. It is best to include postscript figures, i.e..ps or .eps files. There are many ways to do this, but using \package{epsf}is quite straightforward. For example

    0.0

    2

    0.0

    6

    0.1

    0

    0.1

    4

    Nonselves (offdiagonal)

    RSS

    0 4 2 3 4

    95% CI for

    . . . is a figure included just where I wanted it, but many times we also wantfigure to be nicely placed with captions etc. as in figure 1

    Notice how easy it is to control the size of postscript figures . . . 0. 0 2 0 . 0 6

    0 . 1

    0

    0 . 1

    4

    Nonselves (offdiagonal)

    R S S

    0 4 2 3 4

    95% CIfor

    .

    5 Tables

    Here are some examples of tables.

    4

  • 8/3/2019 Learn Latex7

    5/8

    0.0

    2

    0.0

    6

    0.1

    0

    0.1

    4

    Nonselves (offdiagonal)

    RSS

    0 4 2 3 4

    95% CI for

    Figure 1: Residual sums of squares of the differential effect model DE withan approximate 95% confidence interval for .

    subrepresentation dim

    Diagonal

    1D = {f | fij=0, fii=c} 1

    1D = {f | fij=0,

    Pni=1 fii=0} n1

    Off-diagonal

    1O = {f | fii=0, fij=c} 1sym+ = {f | fij=i+j ,

    Pi=0} n1

    sym = {f | fij=fji ,P

    i fij=P

    j fij=0}n(n3)

    2

    alt+ = {f | fij=ij ,P

    i=0} n1

    alt = {f | fij=fji ,P

    ifij=P

    jfij=0}

    (n1)(n2)2

    Name Model formula Conditionsdiagonal1 ii = R ii = + i

    off-diagonalSymmetric1 ij = sym+ ij = i + jsym ij = ij ij = jiAlternatingalt+ ij = i jalt ij = ij ij = jiDifferential EffectsDE ij = i cos + j sin [0, )DE ij = i cos + j sin

    5

  • 8/3/2019 Learn Latex7

    6/8

    Table 1: Orbits ofS

    n in

    3

    (withn >

    3) and in

    4

    (withn >

    4)

    Orbits in 3 Orbits in 4

    Orbit type multiplicity Orbit type multiplicity

    {(i,i,i)} 1 {(i,i,i,i)} 1{(i,i,j)} 3 {(i,i,i,j)} 4{(i,j,k)} 1 {(i,i,j,j)} 3

    {(i,i,j,k)} 6{(i,j,k,l)} 1

    Total 5 Total 15

    Nicely placed tables with captions, numbers and labels like table 1, canbe produced with \begin{table} and \end{table}.

    6 Lists

    Devotees of the bullet point:

    Should use the \begin{itemize} command to start a bulleted list.

    Should use the \item command to add items to the list.

    Should use the \end{itemize} command to end a bulleted list.

    Numbered lists can be useful

    1. because I say so.

    2. because they break op the visual flatness of a page.

    3. because they can be nested which is useful for

    (a) examination questions.

    (b) algorithms.

    (c) er.

    7 Including computer code/output

    Computer code represents a special problem, because it often uses charactersthat have a special meaning in LATEXand is often carefully laid out in a waythat the author does not want messed around by automatic text processing.

    6

  • 8/3/2019 Learn Latex7

    7/8

    Little snippets can be included with the \verb command. The first

    character after \verb is taken as a marker for the beginning of thecharacters to be reproduced verbatim, the second occurance of thischaracter is taken as the end of the verbatim text. For example\verb+q1

  • 8/3/2019 Learn Latex7

    8/8

    1.2 sections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

    1.2.1 sub-sub-sections are also possible . . . . . . . . . . . . 21.3 Spaces, gaps, pagebreaks, etc. . . . . . . . . . . . . . . . . . . 2

    2 Equations 3

    3 Documentation 4

    4 Figures 4

    5 Tables 4

    6 Lists 6

    7 Including computer code/output 6

    8 Bibliography and references 7

    9 Table of contents 7

    References

    8