introduction to unix – cs 21

57
Introduction to Unix – CS 21 Lecture 16

Upload: guy

Post on 19-Mar-2016

28 views

Category:

Documents


0 download

DESCRIPTION

Introduction to Unix – CS 21. Lecture 16. Lecture Overview. LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts Math mode. LaTeX – What Is It?. A general markup language LaTeX is a system that describes how documents should appear on paper - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Introduction to Unix – CS 21

Introduction to Unix – CS 21

Lecture 16

Page 2: Introduction to Unix – CS 21

Lecture Overview LaTeX

History Running and creating LaTeX documents

Documents and Articles Tables Lists Fonts

Math mode

Page 3: Introduction to Unix – CS 21

LaTeX – What Is It? A general markup language LaTeX is a system that describes

how documents should appear on paper Formatting

Margins Section Headings

Special characters

Page 4: Introduction to Unix – CS 21

Other Examples Of Markup Languages HTML

Hypertext markup language Used to describe how web pages appear A little bit of interpretation is still

required and pages may look different on different browsers

SGML Allows for the construction of special

constructs

Page 5: Introduction to Unix – CS 21

Where Did It Come From? TeX

1977 – Donald Knuth Low level formatting details Constructed to make mathematical

books look good LaTeX

1980’s – Leslie Lamport A layer of abstraction on top of TeX

Page 6: Introduction to Unix – CS 21

Why Not Just Use Word? Main reason: Bugs

TeX has long had a bounty for serious bugs that no one can collect on

Secondary reason: LaTeX does what you tell it to LaTeX doesn’t try to out-think you

and put figures where it believes them to be best

Page 7: Introduction to Unix – CS 21

O.K., How Does Latex Work? Latex works on plain text files that are

annotated with commands Commands are of the form: \

command{parameter} Example: \documentclass{article}

Document class tells LaTeX what type of document you are creating

Books have chapters, articles have sections, etc. Most common: article, book, letter, report, slides

Page 8: Introduction to Unix – CS 21

What’s With The Braces? LaTeX uses the braces for grouping

like parenthesis { text } is the same as simply text Commands inside braces (like

changing fonts) only apply inside the braces

Example: { \sf This is in a serif font } And this is not

Page 9: Introduction to Unix – CS 21

What Does A LaTeX File Look Like?

Page 10: Introduction to Unix – CS 21

How Do I Get A Printable Paper Out? Usage: latex document.tex

This creates several files document.aux, document.log,

document.dvi document.idx, document.toc,

document.lof xdvi document.dvi

Views the document dvips –o document.ps document.dvi

Page 11: Introduction to Unix – CS 21

Example LaTeX Run

Page 12: Introduction to Unix – CS 21

What To Do When Something Goes Wrong Latex will pop up with an error message

whenever it encounters a problem Malformed or unknown command

Simplest thing to do: Simply hit return and ignore whatever command LaTeX had problems with

Alternative: type I followed by the correct command to replace the problem Example: I\end{document}

Page 13: Introduction to Unix – CS 21

Sample Run With Problems

Page 14: Introduction to Unix – CS 21

Example Latex File

Page 15: Introduction to Unix – CS 21

Example Output dvi1.JPG

Page 16: Introduction to Unix – CS 21

What Are Comments Doing In A Document? Might seem a little weird coming

from using Word LaTeX can define new commands

and can be confusing at times LaTeX is not a programming

language like perl or awk

Page 17: Introduction to Unix – CS 21

Normal Text All paragraphs of normal text are

simply typed in without any commands.

Spacing is not taken into account, and all spaces get reduced to one space Example:

this is the same this is the same

Page 18: Introduction to Unix – CS 21

Normal Text Example

Page 19: Introduction to Unix – CS 21

Normal Text Output dvi2.JPG

Page 20: Introduction to Unix – CS 21

Common Constructs Italics and Bolding Sectioning Lists Tables Footnotes Mathematical formulas

Page 21: Introduction to Unix – CS 21

Italics And Bolding \emph{text to be emphasized} \bf

Changes the font to a bolder font

Page 22: Introduction to Unix – CS 21

Italic And Bolding Example

Page 23: Introduction to Unix – CS 21

Sectioning CommandsName Level\part -1\chapter 0\section 1\subsection 2\subsubsection 3\paragraph 4\subparagraph 5

Page 24: Introduction to Unix – CS 21

Section Example

Page 25: Introduction to Unix – CS 21

Sectioning Output

Page 26: Introduction to Unix – CS 21

Unnumbered Sections \section{Section Name}

Always numbers the section You can change the format of

sections numbers if you’d like \section*{Section Name}

Will output an unnumbered section

Page 27: Introduction to Unix – CS 21

Unnumbered Example

Page 28: Introduction to Unix – CS 21

Unnumbered Output

Page 29: Introduction to Unix – CS 21

Counters All sections have a counter

associated with them You can adjust this counter if you’d

like \addtocounter{name}{value}

You can create your own counters \newcounter{name} \setcounter{name}{value}

Page 30: Introduction to Unix – CS 21

Counter Example

Page 31: Introduction to Unix – CS 21

Printing Out The Current Section Numbers “The” notation Will print out the current value of

the counter associated \thechapter \thesection \thesubsection

Page 32: Introduction to Unix – CS 21

Ordered And Unordered Lists Ordered lists are handled with the

enumerate construct \begin{enumerate} \end{enumerate}

Unordered lists are handled with the itemize construct \begin{itemize} \end{itemize}

\item

Page 33: Introduction to Unix – CS 21

List Example

Page 34: Introduction to Unix – CS 21

List Output

Page 35: Introduction to Unix – CS 21

Tables Tables are handled with the

tabular environment \begin{tabular}{ FORMAT } \end{tabular}

FORMAT determines how many columns are in the table and how text is arranged

Page 36: Introduction to Unix – CS 21

Format Specifics | represents vertical lines Specific characters tell how to

arrange text in the columns l = Left aligned c = Centered r = Right aligned

Page 37: Introduction to Unix – CS 21

Table Internal Specifics & will separate columns \hline draws horizontal lines \\ ends a line

Page 38: Introduction to Unix – CS 21

First Tabular Example

Page 39: Introduction to Unix – CS 21

First Tabular Output

Page 40: Introduction to Unix – CS 21

More Complex Tabular Example

Page 41: Introduction to Unix – CS 21

Tabular Output

Page 42: Introduction to Unix – CS 21

Footnotes Footnotes are handled with the \

footnote construct \footnote{This is a footnote}

Again, there is an automatic counter that keeps track of your footnotes on a section by section basis

Page 43: Introduction to Unix – CS 21

Mathematical Constructs LaTeX was built on Tex, which was

designed for easy representation of complex mathematical formulas

A special mode for math formulas exists in LaTeX $Math mode$

Page 44: Introduction to Unix – CS 21

Adding Accents

Page 45: Introduction to Unix – CS 21

Accent Output

Page 46: Introduction to Unix – CS 21

Greek Letters

Page 47: Introduction to Unix – CS 21

Greek Letter Output

Page 48: Introduction to Unix – CS 21

Relational Symbols

Page 49: Introduction to Unix – CS 21

Relational Symbols Output

Page 50: Introduction to Unix – CS 21

Various Math Symbols

Page 51: Introduction to Unix – CS 21

Math Symbols Output

Page 52: Introduction to Unix – CS 21

Superscripts and Subscripts In math mode:

\sp{ } ^ as a shortcut

\sb{ } _ as a shortcut

Page 53: Introduction to Unix – CS 21

Complex Math Formula Example

Page 54: Introduction to Unix – CS 21

Complex Math Formula Output

Page 55: Introduction to Unix – CS 21

Vertical Skip And Horizontal Skip \vskip 0.2in \hskip 3in

Page 56: Introduction to Unix – CS 21

When You Don’t Want Any Changes - Verbatim The verbatim environment will

attempt to print out everything exactly as it appears \begin{verbatim} \end{verbatim}

Spacing comes out just as typed in this mode

Page 57: Introduction to Unix – CS 21

Next Time We will look a little more at LaTeX

and examine the Make utility Quiz # 3 will be next Tuesday

(March 8)