introduction to unix – cs 21 lecture 16. lecture overview latex history running and creating latex...

57
Introduction to Unix – CS 21 Lecture 16

Upload: virgil-griffin

Post on 28-Dec-2015

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Introduction to Unix – CS 21

Lecture 16

Page 2: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Lecture Overview LaTeX

History Running and creating LaTeX documents

Documents and Articles Tables Lists Fonts

Math mode

Page 3: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

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 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

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 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

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 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

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 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

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 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

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 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

What Does A LaTeX File Look Like?

Page 10: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

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 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Example LaTeX Run

Page 12: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

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 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Sample Run With Problems

Page 14: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Example Latex File

Page 15: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Example Output dvi1.JPG

Page 16: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

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 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

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 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Normal Text Example

Page 19: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Normal Text Output dvi2.JPG

Page 20: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Common Constructs Italics and Bolding Sectioning Lists Tables Footnotes Mathematical formulas

Page 21: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

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

Changes the font to a bolder font

Page 22: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Italic And Bolding Example

Page 23: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Sectioning Commands

Name Level

\part -1

\chapter 0

\section 1

\subsection 2

\subsubsection 3

\paragraph 4

\subparagraph 5

Page 24: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Section Example

Page 25: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Sectioning Output

Page 26: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

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 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Unnumbered Example

Page 28: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Unnumbered Output

Page 29: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

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 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Counter Example

Page 31: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

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 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

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 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

List Example

Page 34: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

List Output

Page 35: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

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 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

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 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

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

Page 38: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

First Tabular Example

Page 39: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

First Tabular Output

Page 40: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

More Complex Tabular Example

Page 41: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Tabular Output

Page 42: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

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 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

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 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Adding Accents

Page 45: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Accent Output

Page 46: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Greek Letters

Page 47: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Greek Letter Output

Page 48: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Relational Symbols

Page 49: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Relational Symbols Output

Page 50: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Various Math Symbols

Page 51: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Math Symbols Output

Page 52: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Superscripts and Subscripts In math mode:

\sp{ } ^ as a shortcut

\sb{ } _ as a shortcut

Page 53: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Complex Math Formula Example

Page 54: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Complex Math Formula Output

Page 55: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

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

Page 56: Introduction to Unix – CS 21 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

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 Lecture 16. Lecture Overview LaTeX History Running and creating LaTeX documents Documents and Articles Tables Lists Fonts

Next Time We will look a little more at LaTeX

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

(March 8)