+ All Categories
Home > Documents > C151 Multiuser Operating Systems Introduction to LaTeX.

C151 Multiuser Operating Systems Introduction to LaTeX.

Date post: 18-Jan-2016
Category:
Upload: edwina-richard
View: 222 times
Download: 0 times
Share this document with a friend
Popular Tags:
51
C151 Multiuser Operating Systems Introduction to LaTeX
Transcript
Page 1: C151 Multiuser Operating Systems Introduction to LaTeX.

C151 Multiuser Operating Systems

Introduction to LaTeX

Page 2: C151 Multiuser Operating Systems Introduction to LaTeX.

What is LaTex

2

LaTeX is a document markup language and document preparation system.

Page 3: C151 Multiuser Operating Systems Introduction to LaTeX.

Why LaTeX?

3

LaTeX

Separate contents from style

Word

WYSIWYG

Page 4: C151 Multiuser Operating Systems Introduction to LaTeX.

Why not MS Word?

Page 5: C151 Multiuser Operating Systems Introduction to LaTeX.

Why LaTeX?

5

Portable and freeProfessionally crafted layouts are availableThe typesetting of mathematical

formulae is supported in a convenient wayOutput: many different formatsUsers need only to learn a few simple

commands, which specify the logical structure of a document

Complex structures such as footnotes, references, table of contents, and bibliographies can be generated easily

Page 6: C151 Multiuser Operating Systems Introduction to LaTeX.

Required Tools

6

Editor:TeXnic Winedt

Input file:The input for LaTeX is a plain text file with

extension “.tex”You can create it with any text editor.It contains: the text of the document and

commands which tell LaTeX how to typeset the text.

Compiler (www.miktex.org)Standard installation for LinuxWindowsMac

Page 7: C151 Multiuser Operating Systems Introduction to LaTeX.

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

Page 8: C151 Multiuser Operating Systems Introduction to LaTeX.

Compile LaTeXGenerate a dvi file:

>latex file_name.tex

Generate a pdf file

>pdflatex file_name.tex

Page 9: C151 Multiuser Operating Systems Introduction to LaTeX.

9

Documents Structure (1) Every LaTeX document must contain the

following three components:\documentclass{article}\begin{document}\end{document}

Page 10: C151 Multiuser Operating Systems Introduction to LaTeX.

Document Structure (2)Every input file starts with the command:

\documentclass{...}

When all the setup work is done, you start the body of the text with the command:

\begin{document} Now you enter the text mixed with some

useful LaTeX commands.At the end of the document you use the

\end{document}

Page 11: C151 Multiuser Operating Systems Introduction to LaTeX.

\documentclass[options]{class}

First line of all LaTeX documents specifies the {type} of the document and the [stylesheet] used.book report article letter Ready templates: IEEETrans, ACM, etc.

In general, required information is included in LaTeX commands in braces {}, while optional information is included in square brackets [].

\documentclass[ieee]{article}

Page 12: C151 Multiuser Operating Systems Introduction to LaTeX.

\documentclass{article}

12

Page 13: C151 Multiuser Operating Systems Introduction to LaTeX.

\documentclass[twocolumn]{article}

13

Page 14: C151 Multiuser Operating Systems Introduction to LaTeX.

\documentclass{report}

14

Page 15: C151 Multiuser Operating Systems Introduction to LaTeX.

LaTeX Document Example (1)

\documentclass{article}\begin{document}This is some sample text.\end{document}

Page 16: C151 Multiuser Operating Systems Introduction to LaTeX.

LaTeX Document Example (2)\documentclass{article}\begin{document}During the 1960s, many large software

development efforts encountered severe difficulties. Software schedules were typically late, costs greatly exceeded budgets and the finished products were unreliable.

\vspace{10 mm}\noindentPeople began to realize that software

development was a far more complex activity than they had imagined.

\end{document}

Page 17: C151 Multiuser Operating Systems Introduction to LaTeX.

LaTeX Document Example (2): result

Page 18: C151 Multiuser Operating Systems Introduction to LaTeX.

LaTeX Document Example (3)

To add a title to a document use \title and \maketitle\title defines the title and \maketitle inserts it into

the document\maketitle must come after \begin{document}\maketitle usually comes before any other text\title must come before \maketitle

To add an author and date and use \author and \date

\documentclass{article}\begin{document}\title{Hello, World! In Latex}\author{Marc Corliss}\date{2/15/2006}\maketitleHello, World!\\\end{document}

Page 19: C151 Multiuser Operating Systems Introduction to LaTeX.

LaTeX Document Example (3): result

Page 20: C151 Multiuser Operating Systems Introduction to LaTeX.

20

AbstractsTo create an abstract, place your text in an

abstract environment, i.e., between \begin{abstract} and \end{abstract} commands.

The abstract should come immediately after your \maketitle command, but before any \tableofcontents command.

Page 21: C151 Multiuser Operating Systems Introduction to LaTeX.

Sections\section{Section Title}

\subsection{Title}

\subsubsection{Title}

Page 22: C151 Multiuser Operating Systems Introduction to LaTeX.

LaTeX Document Example (4)\documentclass{article}\begin{document}\title{Hello, World! In Latex}\author{Marc Corliss}\date{2/15/2006}\maketitle\begin{abstract}This is example 4.\end{abstract}\section{Hello, World!}Hello Everyone!\\\end{document}

Page 23: C151 Multiuser Operating Systems Introduction to LaTeX.

LaTeX Document Example (4): result

Page 24: C151 Multiuser Operating Systems Introduction to LaTeX.

SpacesWhitespace characters (e.g. blank, tab,

single linebreak) are treated uniformly as “space” by LaTeX.Several consecutive whitespace characters

are treated as one “space”.An empty line between two lines of text

defines the end of a paragraph.Several empty lines are treated in the same

way as one empty line.

Page 25: C151 Multiuser Operating Systems Introduction to LaTeX.

Spaces\documentclass{article}\begin{document}It does not matter whether you enter one or several spaces after a word.

An empty line starts a new paragraph.\end{document}.

Editor view

Document view

Page 26: C151 Multiuser Operating Systems Introduction to LaTeX.

Special CharactersThe following symbols are reserved

characters, that have a special meaning in LaTeX

$ & % # _ { } ~ ^ \ Some of these characters can be used in

your documents by adding a prefix backslash (escape character):

\$ \& \% \# \_ \{ \}The other symbols (and many more!) can be

printed with special commands in mathematical formulae.

Page 27: C151 Multiuser Operating Systems Introduction to LaTeX.

LaTeX CommandsLaTeX commands are case sensitive and start

with a backslash \

\documentclass{article}\begin{document}This is \emph{emphasized} text.\end{document}

Editor view

Document view

Page 28: C151 Multiuser Operating Systems Introduction to LaTeX.

CommentsWhen LaTeX 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.

\documentclass{article}\begin{document}This text is processed. % A comment isn’t\end{document}

Editor view

Document view

Page 29: C151 Multiuser Operating Systems Introduction to LaTeX.

Page StylesLaTeX 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: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 header.

empty - both header and footer empty

Page 30: C151 Multiuser Operating Systems Introduction to LaTeX.

30

Hyphenation There are four hyphens in LaTeX :

1. - (a single dash) is for hyphenating words.

2. -- (two dashes) is for ranges of numbers.

3. --- (three dashes) is for an honest-to-goodness dash between words.

4. $-$ is a minus sign in math mode.

Page 31: C151 Multiuser Operating Systems Introduction to LaTeX.

31

Hyphenation\documentclass{article}\begin{document}My cousin-in-law lived in Germany in 1995--2006; he speaks French---really, he does. His favorite number is $-2$.\end{document}

Editor view

Document view

Page 32: C151 Multiuser Operating Systems Introduction to LaTeX.

32

The LaTeX LogoYou can typeset the LATEX logo with the \LaTeX

command. As with most commands, it consumes any

space behind it, so if it isn't at the end of a sentence, use \LaTeX\ instead.

Page 33: C151 Multiuser Operating Systems Introduction to LaTeX.

33

Appearance of Words\underline{phrase} to underline a phrase,\textbf{phrase} to print a phrase in boldface, and\emph{phrase} to italicize a phrase.

Page 34: C151 Multiuser Operating Systems Introduction to LaTeX.

34

Centering TextBy default, LaTeX will start all text at the left

margin.

If you want to center a title, a table, etc., surround what you want centered with the commands:

\begin{center} and \end{center}.

Page 35: C151 Multiuser Operating Systems Introduction to LaTeX.

LaTeX Example (5) \documentclass{article}\begin{document}\title{\LaTeX\ 1, 2, 3}\author{Liguo Yu}\maketitle\section{Introduction}\begin{center} This is an intruduction!\end{center}\section{Conclusion}Thanks for reading this \textbf{article}.\end{document}

Page 36: C151 Multiuser Operating Systems Introduction to LaTeX.

LaTex Example (5): Result

Page 37: C151 Multiuser Operating Systems Introduction to LaTeX.

37

Bulleted ListsTo create a bulleted list, surround the information

with a \begin{itemize} and an \end{itemize}, and begin each item with an \item.

\documentclass{article}\begin{document}\begin{itemize}\item A bulleted item.\item Another bulleted item.\begin{itemize}\item A nested bulleted item.\end{itemize}\item You get the idea.\end{itemize}\end{document}

Editor view

Document view

Page 38: C151 Multiuser Operating Systems Introduction to LaTeX.

38

Numbered ListsTo create a numbered list, surround the information

with a \begin{enumerate} and an \end{enumerate}, and begin each item with an \item.

\documentclass{article}\begin{document}\begin{enumerate}\item A numbered item.\item Another numbered item.\item You get the idea.\end{enumerate} \end{document}

Editor view

Document view

Page 39: C151 Multiuser Operating Systems Introduction to LaTeX.

Typesetting MathematicsLaTeX has a Math mode for typesetting mathematics.Within a paragraph, math mode is entered between $

characters, or by using the \begin{math} and \end{math} commands

\documentclass{article}\begin{document}Add a squared to b squared to find c squared, e.g. $a^2 + b^2 = c^2$. It’s as easy as that!\end{document}

Editor view

Document view

Page 40: C151 Multiuser Operating Systems Introduction to LaTeX.

Typesetting MathematicsGreek Symbols

\alpha, \beta, \gamma

Superscript, Subscript

x^y x_y x_y^z

Calculus

\int_0^\infty \int{\int}

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

Page 41: C151 Multiuser Operating Systems Introduction to LaTeX.

Typesetting Mathematics

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

Page 42: C151 Multiuser Operating Systems Introduction to LaTeX.

Figures

\begin{figure}\includegraphics{sample.jpg}

\caption{A sample figure.}\end{figure}

Page 43: C151 Multiuser Operating Systems Introduction to LaTeX.

Example\documentclass{article}\usepackage[pdftex]{graphicx}\begin{document}\begin{figure}

\centering\includegraphics{Figure1.jpg}\caption{Depiction of the production of

kernel-based software}\end{figure}\end{document}

Compile:pdflatex file_name

Page 44: C151 Multiuser Operating Systems Introduction to LaTeX.

Result

Page 45: C151 Multiuser Operating Systems Introduction to LaTeX.

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

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

Two Columns

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

Tabular

Page 46: C151 Multiuser Operating Systems Introduction to LaTeX.

Example of table\documentclass{article}\begin{document}\begin{tabular}{|l|r|c|} \hlineDate & Price & Size \\ \hlineYesterday & 5 & Big \\ \hlineToday & 3 & Small \\ \hline\end{tabular}\end{document}

Editor view

Document view

Page 47: C151 Multiuser Operating Systems Introduction to LaTeX.

BibliographiesArticles can be referred to in the text using

the \cite commandThe details of the cited articles are stored

in BibTeX format, in a “.bib” file.BibTeX resolves the citations in the LaTeX

file and generates the required bibliography

Page 48: C151 Multiuser Operating Systems Introduction to LaTeX.

BibliographiesExample entries from test.bib file:

@book{AhR1975,author = {N. Ahmed and K. Rao},title = {Digital signal processing},publisher = {Springer-Verlag},year = {1975},address = {New York},

}

@inproceedings{Aus1989,author = {James Austin and A. Phantom and B. Nom},title = {High Speed Neural Networks},booktitle = {IEE Image Processing and Applications},year = {1989},pages = {28--32},

}

Page 49: C151 Multiuser Operating Systems Introduction to LaTeX.

test.tex file\documentclass[12]{article}\begin{document}\title{Work Study 1, 2, 3}\author{Liguo Yu}\date{\today}\maketitle\section{Introduction}This is an intruduction!\section{Result}By far the most commonly used feature is presented by \cite{Aus1989} and \cite{Ahr1975}.\section{Conclusion}Thanks for reading this article.\bibliographystyle{abbrv}\bibliography{test}\end{document}

Page 50: C151 Multiuser Operating Systems Introduction to LaTeX.

Compile LaTeXWe need to compile .tex and .bib

separately and combine the output together to generate a PDF file

>latex test (compile .tex file)

>bibtex test (compile .bib file)

>pdflatex test (geberate .pdf file)

Might need to run several rounds to successfully combine them

Page 51: C151 Multiuser Operating Systems Introduction to LaTeX.

Result: test.pdf


Recommended