La Te X tutorial Syed Shazli Most of

  • Slides: 42
Download presentation
La. Te. X tutorial Syed Shazli

La. Te. X tutorial Syed Shazli

Most of the material taken from n. Monash University n. Online material available from

Most of the material taken from n. Monash University n. Online material available from Googling…

Preface n n La. Te. X is a typesetting system (not a word processor).

Preface n n La. Te. X is a typesetting system (not a word processor). It is most suited to producing scientific and mathematical documents of high typographical quality.

Why not MS Word?

Why not MS Word?

Advantages and Disadvantages (1) n Advantages of La. Te. X over WYSIWYG: q q

Advantages and Disadvantages (1) n Advantages of La. Te. X over WYSIWYG: q q q professionally crafted layouts are available the typesetting of mathematical formulae is supported in a convenient way users need only to learn a few simple commands, which specify the logical structure of a document.

Advantages and Disadvantages (2) n Advantages of La. Te. X over WYSIWYG: q q

Advantages and Disadvantages (2) n Advantages of La. Te. X over WYSIWYG: q q q complex structures such as footnotes, references, table of contents, and bibliographies can be generated easily for many typographical tasks not directly supported by basic La. Te. X, there exist free add-on packages La. Te. X is highly portable and free

Advantages and Disadvantages (3) n La. Te. X also has some disadvantages: q What

Advantages and Disadvantages (3) n La. Te. X also has some disadvantages: q What you see is not what you get. n q Is this really a disadvantage? Why are you thinking about layout instead of content? The design of a whole new layout is difficult and takes a lot of time. n Templates help you here

La. Te. X Input Files n n n The input for La. Te. X

La. Te. X Input Files n n n The input for La. Te. X is a plain ASCII text file. You can create it with any text editor. It contains q q the text of the document commands which tell La. Te. X how to typeset the text. n n Spaces Special Characters La. Te. X Commands Comments

Spaces n Whitespace characters (e. g. blank, tab, single linebreak) are treated uniformly as

Spaces n Whitespace characters (e. g. blank, tab, single linebreak) are treated uniformly as “space” by La. Te. X. q n Several consecutive whitespace characters are treated as one “space”. An empty line between two lines of text defines the end of a paragraph. q Several empty lines are treated in the same way as one empty line. It does not matter whether you enter one or several spaces after a word. An empty line starts a new paragraph. It does not matter whether you enter one of several spaces after a word. An empty line starts a new paragraph.

Spaces It does not matter whether you enter one or several spaces after a

Spaces It does not matter whether you enter one or several spaces after a word. An empty line starts a new paragraph. It does not matter whether you enter one of several spaces after a word. An empty line starts a new paragraph.

Special Characters n The following symbols are reserved characters, that q n have a

Special Characters n The following symbols are reserved characters, that q n have a special meaning in La. Te. X $&%#_{}~^ Some of these characters can be used in your documents by adding a prefix backslash (escape character): $ & % # _ { } n $ & % # _ { } The other symbols (and many more!) can be printed with special commands in mathematical formulae.

La. Te. X Commands (1) n La. Te. X commands are case sensitive and

La. Te. X Commands (1) n La. Te. X commands are case sensitive and take one of two formats: q q They start with a backslash and have a name consisting only of letters. They consist of a backslash and exactly one special character.

La. Te. X Commands (2) I read that Knuth divides people working with Te.

La. Te. X Commands (2) I read that Knuth divides people working with Te. X into Te. Xnicians and Te. Xperts. Today is March 25 th, 2004. I read that Knuth divides people working with Te. X{} into Te. X{}nicians and Te. X perts. Today is today.

La. Te. X Commands (3) n n n Some commands take a parameter which

La. Te. X Commands (3) n n n Some commands take a parameter which has to be given between curly braces { } after the command name. Some commands support optional parameters which are added after the command name in square brackets [ ]. The next example uses some La. Te. X commands.

La. Te. X Commands (4) This is emph{emphasized} text. Please start a new line

La. Te. X Commands (4) This is emph{emphasized} text. Please start a new line right here!linebreak Thank you! This is emphasized text. Please start a new line right here! Thank you!

Comments n n When La. Te. X encounters a % character while processing an

Comments n n When La. Te. X encounters a % character while processing an input file, it ignores the rest of the present line. This is useful for adding notes to the input file, which will not show up in the printed version. This text is processed. % A comment isn’t This text is processed.

Input File Structure (1) n When La. Te. X 2 e processes an input

Input File Structure (1) n When La. Te. X 2 e processes an input file it expects it to follow a certain structure. Every input file starts with the command: documentclass{. . . } q n This specifies what sort of document you intend to write (article, letter, book, cssethesis, etc. ) After that, you can include global style commands or you can load packages which add new features to the La. Te. X system. To load a package you use the command: usepackage{. . . }

Input File Structure (2) n When all the setup work is done, you start

Input File Structure (2) n When all the setup work is done, you start the body of the text with the command: begin{document} n n Now you enter the text mixed with some useful La. Te. X commands. At the end of the document you use the end{document} command, which tells La. Te. X to finish. Anything which follows this command will be ignored by La. Te. X

Parts of a La. Te. X Document: documentclass {article} {report} {book} {letter} n Basic

Parts of a La. Te. X Document: documentclass {article} {report} {book} {letter} n Basic Classes First line of all La. Te. X documents specifies the {type} of the document and the [stylesheet] used. documentclass[ieee]{article}

A Simple La. Te. X Document documentclass{article} begin{document} This is some sample text. end{document}

A Simple La. Te. X Document documentclass{article} begin{document} This is some sample text. end{document}

A more realistic La. Te. X file documentclass[a 4 paper, 11 pt]{article} usepackage{latexsym} author{S.

A more realistic La. Te. X file documentclass[a 4 paper, 11 pt]{article} usepackage{latexsym} author{S. ~Shazli} title{Dependable Nanocomputing Lab} begin{document} maketitle tableofcontents section{Introduction} Here begins my first article ldots section{Conclusions} ldots{} and here it ends. end{document}

Sections section{Section Title} subsection{Title} subsubsection{Title}

Sections section{Section Title} subsection{Title} subsubsection{Title}

Font size tiny scriptsize footnotesize small normalsize large LARGE huge Huge

Font size tiny scriptsize footnotesize small normalsize large LARGE huge Huge

Page Styles n n La. Te. X supports three predefined header/footer combinations. These are

Page Styles n n La. Te. X supports three predefined header/footer combinations. These are known as page styles. The style parameter of the pagestyle{style} command defines which one to use: q q q n plain prints the page numbers on the bottom of the page in the middle of the footer (default page style) headings prints the current chapter heading and the page number on each page. Footer is empty - both header and footer empty More elaborate headers and footers can be created using the fancyheadings package

Typesetting Mathematics n n La. Te. X has a special mode for typesetting mathematics,

Typesetting Mathematics n n La. Te. X has a special mode for typesetting mathematics, called “math mode”. Within a paragraph, math mode is entered between $ characters, or by using the begin{math} and end{math} commands To find the square of the hypotenuse, add a squared to b squared to find c squared, e. g. $a^2 + b^2 = c^2$. It’s as easy as that! To find the square of the hypotenuse, add a squared to b squared to find c squared, e. g. . It’s as easy as that!

Typesetting Mathematics Greek Symbols alpha, beta, gamma Superscript, Subscript x^y x_y Calculus int_0^infty frac{partial

Typesetting Mathematics Greek Symbols alpha, beta, gamma Superscript, Subscript x^y x_y Calculus int_0^infty frac{partial u}{partial x} x_y^z int{int}

Typesetting Mathematics x = frac{-b pm sqrt{b^2 -4 ac} } {2 a}

Typesetting Mathematics x = frac{-b pm sqrt{b^2 -4 ac} } {2 a}

Typesetting Mathematics n n In a research paper or thesis, you will often want

Typesetting Mathematics n n In a research paper or thesis, you will often want to number equations and refer to them in the text This is done using the equation environment, and the commands label and ref … it is clear that e > 0. (1) From Equation 1 it follows that. . . n ldots it is clear that begin{equation} epsilon > 0. label{eq: eps} end{equation} From Equation~ref{eq: eps} it follows that ldots (note that label and ref are used with figures and tables too)

Typesetting Mathematics n Matrices are produced using the textbf{array} environment. Example: The emph{characteristic polynomial}

Typesetting Mathematics n Matrices are produced using the textbf{array} environment. Example: 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 given by the formula [ chi(lambda) = left| begin{array}{ccc} lambda - a & -b & -c \ -d & lambda - e & -f \ -g & -h & lambda - i end{array} right|. ]

Including Graphics n La. Te. X 2 e includes a standard package for including

Including Graphics n La. Te. X 2 e includes a standard package for including Post. Script graphics in your document. Load it using usepackage{graphics} n A figure can be included using, for example, begin{figure}[ht] begin{center} includegraphics[width=140 mm]{mypic. ps} end{center} caption{An example of a figure. } label{fig: example} end{figure}

Figures and Tables n Figures & Tables cannot be broken between pages n They

Figures and Tables n Figures & Tables cannot be broken between pages n They are “floated” begin{figure} includegraphics{sample} caption{A sample figure. } end{figure}

Tabular n Columns q q n Two Columns begin{tabular}{|…|…|} end{tabular} Rows q q &

Tabular n Columns q q n Two Columns begin{tabular}{|…|…|} end{tabular} Rows q q & - Split text into columns \ - End a row hline - Draw line under row e. g. 123123 & 34. 00\ hline l = automatically adjust size, left justify r = automatically adjust size, right justify p = set size e. g p{4. 7 cm} c = centre text

Example of table begin{tabular}{|l|r|c|} hline Date & Price & Size \ hline Yesterday &

Example of table begin{tabular}{|l|r|c|} hline Date & Price & Size \ hline Yesterday & 5 & Big \ hline Today & 3 & Small \ hline end{tabular}

Cross-referencing label{marker} ref{marker} pageref{marker} Example: section{Introduction} label{intro} … n As mentioned in section ref{intro}

Cross-referencing label{marker} ref{marker} pageref{marker} Example: section{Introduction} label{intro} … n As mentioned in section ref{intro} in pageref{intro}

Bibliographies n n n Articles can be referred to in the text using the

Bibliographies n n n Articles can be referred to in the text using the cite command The details of the cited articles are stored in Bib. Te. X format, in a “. bib” file. Bib. Te. X resolves the citations in the La. Te. X file and generates the required bibliography

Bibliographies By far the most commonly used feature is color (e. g.  cite{NBE

Bibliographies By far the most commonly used feature is color (e. g. cite{NBE 1993, Ja. V 1996 , Sm. C 1996 a}), usually computed in a color space thought to be ``perceptually accurate'' (e. g. HSV cite{Sm. C 1996 a} or CIE cite{STL 1997}). By far the most commonly used feature is color (e. g. [1, 2, 3]), usually computed in a colour space thought to be “perceptually accurate” (e. g. HSV [3] or CIE [4].

Bibliographies n Example Bib. Te. X entries from a. bib file: @book{Ah. R 1975,

Bibliographies n Example Bib. Te. X entries from a. bib file: @book{Ah. R 1975, author = title = publisher = year = address = {N. Ahmed and K. Rao}, {Orthogonal transforms for digital signal processing}, {Springer-Verlag}, {1975}, {New York}, } @inproceedings{Aus 1989, author = {James Austin and A. Phantom and Also Phantom}, title = {High Speed Invariant Recognition Using Adaptive Neural Networks}, booktitle = {IEE 3 rd International Conference on Image Processing and its Applications}, year = {1989}, pages = {28 --32}, abstract = {A method is described which. . . }, }

Running La. Te. X n The simplest way to run La. Te. X on

Running La. Te. X n The simplest way to run La. Te. X on a source document is to do so at the UNIX command line: >latex test. tex n These will be: test. aux # the auxiliary file that La. Te. X will use in subsequent passes to resolve references to figures, tables, citations etc. test. log # a log file that contains information about the La. Te. X run test. dvi # the De. Vice Independent output file. This is the typeset document, ready for conversion to postscript or other printable formats

Running La. Te. X n n We can view the document we have created

Running La. Te. X n n We can view the document we have created using a DVI viewer. The most common one under UNIX is xdvi. Type >xdvi test to see the typeset document It is important to realise that La. Te. X sometimes needs to be run several times to resolve all references.

Creating Latex Files Your Latex File (a text file) Your Bibtex File Latex compile

Creating Latex Files Your Latex File (a text file) Your Bibtex File Latex compile x 3 Bibtex compile x 2 Latex compile x 3 Device independent output. dvips compile x 1 Your Postscript File

Output Formats n n n 1 . dvi. ps. pdf. rtf. html. xml Device

Output Formats n n n 1 . dvi. ps. pdf. rtf. html. xml Device Independent Post Script PDF Rich Text Format HTML XML

Further reading n http: //www. ctan. org/tex-archive/info/lshort/english/ n Google

Further reading n http: //www. ctan. org/tex-archive/info/lshort/english/ n Google