Notes
Slide Show
Outline
1
"Stephanie Rednour"
  • Stephanie Rednour
  • Robert Misior
  • May 5, 2006
2
A Brief History of TeX
  • Pronounced “Tech” because it’s supposed to be the Greek letters Tau, Epsilon, and Chi.
  • TeX is a typesetting program used to produce documents.  It has the same goal as Microsoft Word, but the method to achieve the end document is different.
  • Word is a WYSIWYG (What You See Is What You Get) system.  This means that what you see on the screen is approximately what prints out on paper
  • TeX is a markup language, similar to HTML, where the user enters the format for the document as commands, as well as entering the text of the document.


3
A Brief History of LaTeX
  • Pronounced “Lay-Tech” or “Lah-Tech”
  • A supplement to TeX designed by Leslie Lamport (hence the “La” in LaTeX)
  • In LaTeX itself, the word is written
  • In ASCII we use LaTeX
4
WYSIWYG versus Markup
5
WYSIWYG versus Markup
6
WYSIWYG versus Markup
7
LaTeX Commands
  • LaTeX commands are CASE SENSITIVE!
  • They always start with a \ and are followed by either a name with only letters, or by a single non-letter (see Special Characters)
  • Any whitespace after a command is ignored; put {V} to get a space after a command
    • NOTE: the V symbol represents one space

8
LaTeX File Structure
  • preamble
9
\documentclass[options]{class}
  • class – specifies the type of document to be created
    • Ex. article, proc, minimal, report, book, slides
  • options – parameters which allow the settings for the document class to be changed
    • Ex. 10 pt, 11 pt, 12 pt
      • a4paper, letterpaper
      • fleqn, leqno
      • titlepage, notitlepage
10
\documentclass[options]{class}
11
Common Packages
  • Any of the below can be used as the class argument of \usepackage[options]{class}
  • doc - documentation
  • exscale – scaled versions of the math font
  • fontenc – LaTeX font encoding
  • ifthen – allows logical commands
  • latexsym – symbol font
  • makeidx – produces indexes
  • syntonly – processes a document without generating the output; saves time
  • inputenc – allows specification of an input encoding (ASCII, Apple, etc…)
  • amsmath – special math commands
12
More Document Commands
  • Setting the Page Style
    • \pagestyle{style}
      • style – sets the type of header or footer
        • ex. plain, headings, empty…
    • \thispagestyle{style} – applies the style to only the current page.
13
 
14
More Document Commands
  • Including Files
    • \include{filename}
      • filename – name of another document that you want to include somewhere in this document.
        • NOTE: a new page is started where the document is inserted
    • \includeonly{filename1, filename2, …}
      • \include commands in the body will only work for filenames given as arguments to this command.
      • This command goes in the preamble, the other commands listed here go in the body.
    • \input{filename}
      • works the same as the \include command, but LaTeX reorganizes the page breaks after including the new document.
15
Include Example Code
16
Include Example PDF File
17
Comments
  • Use % comment text to add a single line of comments
  • To add multiple lines of comments, use:
    • \begin{comment}
    • comment text
    • \end{comment}
    • *need to use package verbatim
18
Whitespace
  • Whitespace is any empty space on the page
  • A single “V” space and multiple spaces “VVVV” are all handled as a single space by LaTeX
  • A single line break is also handled as a single space by LaTeX
  • A double line break signals the end of a paragraph
  • A period “.” after a lowercase letter is taken by LaTeX to be the end of a sentence and therefore it automatically inserts a double space
  • A period after an uppercase letter is taken as an abbreviation so no extra space is added
19
Whitespace, cont…
  • To indicate that a period after a lowercase letter is part of an abbreviation, use .~
  • Use \@. to indicate a period after an uppercase letter is the end of a sentence and not an abbreviation
  • To remove the extra space after all periods, use the command \frenchspacing
  • \/ is called the “Italic Correction.”  It inserts a small space after an italic letter to compensate for the slant. (\/ is \ and / not the letter V)
  • Any whitespace after a command is ignored; put {V} to get a space after a command


20
Whitespace, cont…
  • To insert horizontal blank space within a paragraph, use: \hspace{n} or \hspace*{n}
    • the * tells LaTeX that even if there is a line break, don’t ignore the horizontal space
    • n is the length of the blank space given in the units shown to the right.


21
Whitespace Example Code
22
Whitespace Example PDF File
23
Special Characters
  • The characters to the right are reserved in LaTeX for special purposes, so to show them you must use a code.
  • NOTE: In \~{n}, the n represents the letter over which the ~ goes.



24
Special Strings
  • Strings
    • \TeX, \LaTeX, \LaTeX2e display the formatted text.  For example \LaTeX shows
    • \today displays the current date
25
Special Symbols
26
Common Body Typesetting Commands
  • Line Breaks
    • \\ or \newline – starts a new line but not a new paragraph.
    • \\* starts a new line but prohibits a page break at that location.
    • With \linebreak[n] and \nolinebreak[n] LaTeX tries to position a line break (or not position one) that looks good based on the value of n
      • n can be an integer from 0-4; the higher the number the stronger the recommendation to LaTeX to perform the line break.
    • In general, LaTeX tries to position new lines so that the text is evenly spaced.
27
Common Body Typesetting Commands
  • Page Breaks
    • \newpage – starts a new page
    • Similar to \linebreak[n], with \pagebreak[n] and \nopagebreak[n] LaTeX tries to even out the right border of the page based on the value of n (0-4)
  • \sloppy loosens LaTeX’s even positioning; \fussy restores LaTeX back to it’s normal positioning
28
Hyphenation
  • LaTeX automatically hyphenates words as necessary to even out the right border.
  • \hyphenation{wordlist} – this command goes in the preamble; it allows the default hyphenating of LaTeX to be overridden; the words given in wordlist are hyphenated as specified by the \- in the words; a lack of \- in a word tells LaTeX not to hyphenate that word at all.
  • In the body of the text, \- can also be used to suggest where a hyphen should go.
29
Hyphenation cont…
  • Words with special characters are not automatically hyphenated.  The hyphenation must be specified.
  • To prevent hyphenation of words, use \mbox{text} or \fbox{text}
    • Any words in text are kept together under all circumstances.  To show just the text, use \mbox, to draw a box around the text, use \fbox.
30
Hyphenation Example Code
31
Hyphenation Example PDF File
32
Font Types
  • \rm – roman
  • \sl – slanted roman
  • \it – italic
  • \tt – typewriter
  • \bf – boldface
  • \em – emphasis
  • \emph{text} – same as above, but this doesn’t change the font and will work to emphasize any font
  • \underline{text} – also doesn’t change the font, just underlines it
33
Running LaTeX from Command Line
  • LaTeX input files must end in .tex and be stored as a plain ASCII text file, not RTF or any other format
  • To run LaTeX on a file, enter
    • latex blah.tex
    • If no errors are found, this will generate a .dvi file
  • If there is an error, LaTeX will give some indication and stop processing the file; Ctrl-D will return you to the command line (exits LaTeX)
  • To convert to PS, you can use
    • dvips –Pcmz blah.dvi –o blah.ps
34
Mathematical Expressions
  • To insert a mathematical expression directly into a line of text, surround the expression with $expression$.
  • To insert an expression in its own line, surround it by \[expression\].


35
Mathematical Expressions, cont…
  • To insert numbered or multiline expressions, use the following:


36
Mathematical Expressions Examples
37
Mathematical Font Types
  • \mathnormal - default
  • \mathit – math italic
  • \boldmath – math bold (closed with \unboldmath)
  • \mathbf – boldface
  • \mathrm – roman
  • \mathsl – slanted roman
  • \mathtt – typewriter
  • \mathcal – calligraphic (symbols)
38
Mathematical Font Examples
39
Whitespace in Mathematical Expressions
  • \quad – inserts a blank space the size of the letter “M”
  • \, - inserts a thin blank space
  • \! – removes a thin blank space
40
Mathematical Expression Syntax
  • Prime:
    • $n’$ –
  • Superscripts and Subscripts:
    • $a^b$ –
    • $a_b$ –
    • $a^{bc}$ –
    • $a_{bc}$ –
    • They can be nested as well, like $a_{b_c}$ –
  • Fractions:
    • $\frac{numerator}{denominator}$ – numerator and denominator can be mathematical expressions
41
Mathematical Expression Syntax, cont…
  • Square Roots:
    • \sqrt[n]{expression}, where n is the degree of the root
  • Large Delimiters:
    • \left( expression \right), where ( and ) are the delimiters (these could also be [ ], \{ \}, or | | also)
    • \over( expression \under)
    • \overline{expression} and \underline{expression} create a line over or under an expression
  • Text in an Expression:
    • to insert text so its not in math italic, use \mbox{text}
42
Mathematical Expression Syntax Examples
43
Mathematical Expression Symbols:
Lowercase Greek
44
Mathematical Expression Symbols:
Uppercase Greek
45
Mathematical Expression Symbols:
Miscellaneous
46
Mathematical Expression Operators:
Large
47
Mathematical Expression Operators:
Binary
48
Mathematical Expression Operators:
Relations
49
Mathematical Expression Operators:
Arrows
50
Mathematical Expression
Openings and Closings
51
Functions in Mathematical Expressions
  • Conventionally functions are not given in italics, so LaTeX presents the following standard functions automatically in Roman; any functions not on this list require a \mbox{} to convert the font.
    • \arccos, \arcsin, \arctan, \arg, \cos, \cosh, \cot, \coth, \csc, \deg, \det, \dim, \exp, \gcd, \hom, \inf, \ker, \lg, \lim, \liminf, \limsup, \ln, \log, \max, \min, \Pr, \sec, \sin, \sinh, \sup, \tan, \tanh
    • Example Code: Example PDF File:
52
Mathematical Accents
53
Cross References
  • To point the user to other locations in the document in a dynamic way, such as figures, sections, etc…
  • \label{marker} – labels this location with the label marker
  • \ref{marker} – generates the number of the section, subsection, figure, table, or theorem where the label marker is
  • \pageref{marker} – generates the page number where the label marker is
54
Cross References Example
55
Footnotes
  • Automatically inserts the superscript number and the footnote at the bottom of the page
    • \footnote{footnotetext}
56
Footnotes Example
57
Environments
  • Used to set various properties for several lines of text
  • In general the format is:
    • \begin{environment} text \end{environment} where environment is the name of the environment
58
Environments, cont …
  • List Environments:
    • enumerate – creates enumerated lists
    • itemize – creates simple bulleted lists
    • description – format for terms and definitions
  • Justification Environments:
    • flushleft, center, flushright – justifies text like the name implies
  • abstract – special environment for adding an abstract to a scientific publication
59
Listing Environment Examples
60
Quotation Environments
  • quote – indents quotes up to one paragraph in length
  • quotation – indents multiparagraph quotes, further indenting the first line of each paragraph
  • verse – for quoting poems because it doubly indents wrapped lines so each line of the poem is easy to identify
61
Quotation Example Code
62
Quotation Example PDF File
63
Verbatim Environment
  • Generates text just as it is entered, without any LaTeX commands being executed; this is useful for showing LaTeX commands in the text
  • Using \begin{verbatim*} shows a V for each space in the text
64
Verbatim Example
65
minimal – Document class
  • The bare minimum (3 lines) that is needed in the LaTeX class file.
  • Sets only text width and height and defines \normalsize
  • Intended for debugging and testing.
  • Base used for designing a new class that is radically different from the structure supplied by the article class.
66
proc – Proceedings class
  • A document class for conference proceedings, based on article.


  • Provides two column output.
  •  \copyrightspace makes the blank space for a copyright notice (can be used after first \footnote command).
  • LaTeX automatically numbers the output pages.
  • It is a good idea to identify the paper.
67
report – Document class
  • It is a less complicated version of the book class, often used for theses and other short multi-chapter documents.


  • Parts available in report:
    • \chapter{chapter title}
    • \section{section title}
    • \subsection{subsection title}
    • \paragraph{paragraph title}
    • \subparagraph{subparagraph title}
68
slides – Document class
  • Uses a bigger based font size, suitable for transparency presentations, and provides an easy way to make overlays.
    • \documentclass{slides}
    • \begin{document}
    • \begin{slide}
    • \begine{itemize}
    • \item Item 1
    • \item My item 2
    • \end{itemize}
    • \end{slide}
    • \begin{slide}
    • ….
    • \end{slide}
    • \end{documemt}
69
Sectioning a Document
  • It depends on the class what types of sections are available.
  • Article:
    • \section{…}, \subsection{...}, \subsubsection{…}
    • \paragraph{…}, \subparagraph{…}
    • \part{…}
  • Report or Book:
    • \chapter{…}
    • \appendix
  • To leave a section out of the Table of Contents, use a * after the command, for example \chapter*{…}
70
Sectioning a Document, cont…
  • \tableofcontents – automatically generates the TOC at the location this command is issued; the document must be compiled  2-3 times to get the TOC to be generated properly.
  • To specify a short version of a section title for the TOC, place it in [] after the section command:
    • \chapter[shorttitle]{longtitle}
  • \maketitle – generates the title of the document at the location it is issued; the contents of the title are set using the following:
    • \title{title}, \author{author}, and \data{data}
    • NOTE: for several authors, separate the names with an \and
71
Index Environment
  • Create index entries using the theindex environment
    • \begin{theindex}
      • indexentries
    • \end{theindex}
  • This environment is 2-column with the header INDEX
  • Entries are made using \item, \subitem, \subsubitem, and \indexspace (leaves a blank line in the index)
72
MakeIndex
  • MakeIndex is a program that can be run on a LaTeX file that contains MakeIndex commands
  • To use MakeIndex on a LaTeX file, include \usepackage{makeidx} in the preamble
  • To supply the words for the index, use
  • \index{keyword}
  • Commands may be used as keywords
  • To create subitems use
  • \index{main_keyword!sub_keyword}
  • \index{main_keyword!sub_keyword!sub_sub_keyword}
  • When LaTeX runs with the \makeindex command, it creates a .idx file
  • This file contains \indexentry{keyword}{pagenumber} entries for each keyword in the index
73
Running MakeIndex
  • The input to MakeIndex is the .idx file
    • makeindex filename.idx
  • The output is a .ind file that contains the index
  • To include the index in the document include \printindex at the location you want the index inserted
  • After the .ind file has been created, run LaTeX on the document again to insert the index


74
MakeIndex Options
  • The MakeIndex program has several options you can set when it is run from the command line
75
Special Book Class Commands
  • \frontmatter – goes immediately after the \begin{document} command; page numbering in this section is in Roman numerals and sections aren’t enumerated, but they will be included in the TOC
  • \mainmatter – contains the body of the text (chapters), uses Arabic page numbering, and the counter is reset (doesn’t continue from the frontmatter)
  • \appendix – comes after the main body of the text, each chapter in the appendix is enumerated by letters.
  • \backmatter – contains the bibliography, index, etc…
76
Book Class Example Code
77
Book Example PDF File
78
Tables and Columns
  • The easiest way to align text in columns can be accomplished by using tabbing
  • \begin{tabbing}
  • column 1 \= column 2 \= column 3 \\
  • txt in col1 \> txt in col2 \> txt in col 3\\
  • Txt in col1 \> \> txt in col3\\
  • ……..
  • ……..
  • \end{tabbing}
79
tabbing commands
  • Following commands can be used inside of tabbing environment
  • \=    (set tab)
  • \>    (advance to next tab stop)
  • \<    (the left of the local margin )
  • \+    (indent; move margin right)
  • \-     (unindent; move margin left)
  • \’     (flush against the current column's tab stop)
  • \`     (flushed right against any tab stop)
  • \\     (end of line; newline)
  • \kill  (ignore preceding text; use only for spacing)
  • \hspace[*]{len} adds horizontal space


  • The accents inside tabbing are created by using \a=, \a',  \a`


80
tabbing
  • tabbing environment can be used only in paragraph mode.
  • tabbing starts new paragraph.
  • tabbing can be split across  multiple pages.
  • The width of the columns is determined by setting tab stops.
81
tabbing example
  • \begin{tabbing}
  • \bf Type\quad\= \bf Quality\quad\= \bf Color\quad\= \bf Price\\[2ex]
  • paper \> med. \> white \> low\\
  • letter \>good\>brown\>high\\
  • \> \>red
  • \end{tabbing}
82
Making Tables with tabular
  • Creates tables with optional horizontal and vertical lines.
  • tabular environment can be used in any mode not only in paragraph.
  • Table is treated as one letter that cannot be split across pages.
  • The width of the columns is determined automatically by LaTeX.
83
tabular syntax
  • \begin{tabular}[pos]{cols}
  •                         Or
  • \begin{tabular*}{width}[pos]{cols}


  • The * makes the width argument mandatory (specifies the width of the tabular environment)
84
tabular pos
  • pos Specifies the vertical position of the whole tabular environment (recall that it is a box). The default is to align the box on the center of the environment.
  •    t - align on top row
  •    b - align on bottom row


85
tabular cols
  • cols Specifies the column formatting. It consists of a sequence of the following specifies, at least one for each of the columns.
  • l - A column of left-aligned items.
  • r - A column of right-aligned items.
  • c - A column of centered items.
  • p{wd} - Produces a column which can be multiple lines.
  • | - A vertical line the full height and depth of the environment.
  • @{text} - This inserts text in every row.
  • *{num}{cols} - Equivalent to num copies of cols, where num is any positive integer and cols is any list of column-specifiers, which may contain another *-expression.


86
tabular example
  • \begin{tabular}{|l|c|c|r|} \hline
  • Type & Quality & Color & Price \\ \hline \hline
  • paper & med. & white &low\\
  • letter &good & brown & high\\
  • & & red & \\ \hline
  • \end{tabular}
87
tabular example1
  • \begin{figure}
  • \centering
  •   \caption{$G_{(4,7)}(u)$}
  • \begin{tabular}{c c c c c }
  •  &  &  & $a$ &$a$  \\
  •  &  &  & $a$ &$a$  \\
  •  &  & $b$ & $\diamond$ &  \\
  •  & $b$ &$b$  & $b$ &  \\
  •  $a$& $\diamond$ & $b$ &  &  \\
  •  & $\diamond$ &  &  &  \\
  • \end{tabular}
  • \end{figure}
88
tabular example2
  • \begin{figure}[h]
  • \centering
  •   \caption{Ordering of $w$}
  • \begin{tabular}{|c|c|l|l|c|c|} \hline
  • $k_{0}$ & $p_{0,k_{0}} $ & $v_{0,k_{0}} $ &  $v'_{0,k_{0}} $ & $p_{0,l_{0}}$ & $l_{0}$  \\  \hline
  • $5$ & & ${\diamond}cbba$  & ${\diamond}cbba$ &  & $5$ \\
  • $4$ &  & $a$  & $cbba$ &  & $4$ \\
  • $3$ &  & $a{\diamond}cbba$  & $bba$ &  & $3$ \\
  • $2$ &  & $ba$  & $ba$ &  & $2$ \\
  • $1$ &  & $bba$  & $a$ &  & $1$ \\
  • $0$ & $1$ & $cbba$  & $a{\diamond}cbba$ &  & $0$ \\ \hline
  • \end{tabular}
  • \end{figure}
89
tabular example3
  • Advanced options of tabular:
  • \begin{figure}[h]
  • \centering
  •   \caption{Ordering of $w$}
  • \begin{tabular}{|c|c|l|l|c|@{\hspace{0.2in}}c|} \hline
  • $k_{0}$ & $p_{0,k_{0}} $ & $v_{0,k_{0}} $ &  $v'_{0,k_{0}} $ & $p_{0,l_{0}}$ & $l_{0}$  \\  \hline
  • $5$ & & ${\diamond}cbba$  & ${\diamond}cbba$ &  & $5$ \\
  • $4$ &  & $a$  & $cbba$ &  & $4$ \\
  • $3$ &  & $a{\diamond}cbba$  & $bba$ &  & $3$ \\
  • $2$ &  & $ba$  & $ba$ &  & $2$ \\
  • $1$ &  & $bba$  & $a$ &  & $1$ \\
  • $0$ & $1$ & $cbba$  & $a{\diamond}cbba$ &  & $0$ \\ \hline
  • \end{tabular}
  • \end{figure}
  • The @ parameter can be used to insert text or commands in every field of specified column.
90
array example
  • \begin{figure}[h]
  • \centering
  •   \caption{Ordering of $w$}
  • $
  • \begin{array}{|c|c|l|l|c|c|} \hline
  •  k_{0} & p_{0,k_{0}}  & v_{0,k_{0}}  &  v'_{0,k_{0}}  & p_{0,l_{0}} & l_{0} \\  \hline
  •  5 &  & \diamond cbba  & \diamond cbba &  & 5   \\
  •  4 &  & a  & cbba &  & 4  \\
  •  3 &  & a{\diamond}cbba  & bba &  & 3  \\
  •  2 &  & ba  & ba &  & 2  \\
  •  1 &  & bba  & a &  & 1  \\
  •  0 & 1 &cbba &a{\diamond}cbba &  & 0  \\ \hline
  • \end{array}
  • $
  • \end{figure}


  • Array syntax resembles tabular.
91
Floating Bodies
  • The idea behind floating bodies is to solve a problem of figures or tables that are too big to fit on a current page while also filling current page with body text.


  • Latex offers two environments for floating bodies one for tables and one for figures.
92
figure
  • \begin{figure}[placement]
  • body of the figure
  • \caption{figure title}
  •  \end{figure}
93
table
  • \begin{table}[placement]
  • body of the table
  • \caption{table title}
  • \end{table}


  • (optional form of table exists table*, puts table in a single column when in two column mode)
94
table figure [placement]
  • Optional parameter for table and figure determines where LaTeX will try to place your floating body
  • h Here - at the position in the text where the table environment appears.
  • t Top - at the top of a text page.
  • b Bottom - at the bottom of a text page.
  • p Page of floats - on a separate float page, which is a page containing no text, only floats.
  • ! without considering most of the internal parameters which could stop this float from being placed.


95
minipage - environment
  •     the minipage environment can be used to put one or more paragraphs inside of a picture environment or as a table item


  •    \begin{minipage}[pos]{width}
  •        text
  •    \end{minipage}



  • width - Mandatory specifies the width of the minipage.
  • pos - t -for top or b for bottom.


96
minipage example
  • \begin{minipage}[b]{0.5\linewidth}
  •      \setlength{\unitlength}{1mm}
  •      \begin{picture}(50,40)
  •           \put(30,30){\circle{30}}
  •           \put(30,30){\circle*{5}}
  •     \end{picture}\\
  •     Drawing with LaTeX example circle.
  • \end{minipage}
97
Side-by-Side Figures
  •   Tabular can be combined with minipage to place figures side by side. It can also be used to create one figure out of two or more figures.
98
Side-by-side Figures Example a)
  •  \begin{figure}[t]
  • \begin{tabular}{|c|c|} \hline
  • \bf{Normal:} & \bf{Reverse:} \\ \hline
  •  \begin{minipage}[b]{0.5\linewidth}
  • \centering
  •   \caption{Ordering of $w$}
  • \begin{tabular}{|c|c|l|l|c|c|} \hline
  • $k_{0}$ & $p_{0,k_{0}} $ & $v_{0,k_{0}} $ &  $v'_{0,k_{0}} $ & $p_{0,l_{0}}$ & $l_{0}$  \\  \hline
  • $5$ & $$ & ${\diamond}cbba$  & ${\diamond}cbba$ & $$ & $5$ \\
  • $4$ & $$ & $a$  & $cbba$ & $$ & $4$ \\
  • $3$ & $$ & $a{\diamond}cbba$  & $bba$ & $$ & $3$ \\
  • $2$ & $$ & $ba$  & $ba$ & $$ & $2$ \\
  • $1$ & $$ & $bba$  & $a$ & $$ & $1$ \\
  • $0$ & $1$ & $cbba$  & $a{\diamond}cbba$ & $$ & $0$ \\ \hline
  • \end{tabular}
  • \end{minipage}  &
99
Side-by-side Figures Example b)
  • \begin{minipage}[b]{0.5\linewidth}
  • \centering
  •   \caption{Reverse ordering of $w$}
  • \begin{tabular}{|c|c|l|l|c|c|} \hline
  • $k_{1}$ & $p_{1,k_{1}} $ & $v_{1,k_{1}} $ &  $v'_{1,k_{1}} $ & $p_{1,l_{1}}$ & $l_{1}$  \\  \hline
  • $5$ & $$ & ${\diamond}a$  & ${\diamond}a$ & $$ & $5$ \\
  • $4$ & $$ & $a$  & $c{\diamond}a$ & $$ & $4$ \\
  • $3$ & $$ & $abbc{\diamond}a$  & $bc{\diamond}a$ & $$ & $3$ \\
  • $2$ & $$ & $bbc{\diamond}a$  & $bbc{\diamond}a$ & $$ & $2$ \\
  • $1$ & $$ & $bc{\diamond}a$  & $a$ & $$ & $1$ \\
  • $0$ & $5$ & $c{\diamond}a$  & $abbc{\diamond}a$ & $$ & $0$ \\ \hline
  • \end{tabular}
  • \end{minipage} \\
  • & \\ \hline  % extra space
  • \end{tabular}
  • \end{figure}


100
Side-by-side Figures Results
101
Graphics in LaTeX
  • The 3 steps required to import images:
  • Export picture in EPS format.
  • Load the graphicx package:
  • \usepackage[driver]{graphicx}
  • Include your graphics file:
  • \includegraphics[key=value,key=value,…]{file}


  • (driver usually dvips )
  • Possible keys; width, height, angle, scale, angle, more options ...


102
Floating Bodies and Graphics
  • Using floating bodies and Graphics together:


  • \begin{figure}
  • \centering
  • \includegraphics[angle=90,width=0.75\textwidth]{pic.eps}
  • \caption{A picture, included from pic.eps file.}
  • \end{figure}
103
Making gaphics with LaTeX
  • The picture environment allows creating graphics using latex commands.
  • (circles, eclipses, lines, vectors,…)


  • \begin{picture}(x,y)
  • ….
  • ….
  • \end{picture}


104
picture environment
  • Some commands available in picture environment:
  • \setlength{\unitlength}{1.5in}
  • \put(x,y){object}
  • \multiput(x,y)(Δx, Δy){n}{object}
  • Bezier curves :
  • \qbezier(x1,y1)(x2,y2)(x3,y3)
105
Examples of using picture
  • \begin{figure}
  • \centering
  • \setlength{\unitlength}{5cm}
  • \begin{picture}(1,1)
  • \put(0,0){\line(0,1){1}}
  • \put(0,0){\line(1,1){1}}
  • \put(0,0){\line(1,0){1}}
  • \put(0,0){\line(1,2){.5}}
  • \end{picture}
  • \caption{Drawing with LaTeX}
  • \end{figure}
106
Example 2 of using picture and figure
  • \begin{figure}
  • \centering
  • \setlength{\unitlength}{5cm}
  • \begin{picture}(1,1)
  • \put(0,0){\vector(0,1){1}}
  • \put(0,0){\vector(1,1){1}}
  • \put(0,0){\vector(1,0){1}}
  • \end{picture}
  • \begin{caption}
  • Drawing with LaTeX example $f(x) = y$
  • \end{caption}
  • \end{figure}
107
Drawing circles using picture
  • \begin{figure}
  • \centering
  • \setlength{\unitlength}{1mm}
  • \begin{picture}(50,40)
  • \put(30,30){\circle{30}}
  • \put(30,30){\circle*{5}}
  • \end{picture}
  • \caption{Drawing with LaTeX example 3 circle.}
  • \end{figure}


108
Adding new commands
  • Existing LaTeX commands are sufficient for most situations. But if there is something that you think is missing you can always add  or modify using following commands:
  • \newcommand
  • \renewcommand
  • \providecommand


109
newcommand command
  • \newcommand{name}[num][opt]{def}


  • name – the name of your new command.


  • num – is an optional parameter specifying number of arguments the new command requires if not present the default is 0.


  • opt – number of arguments that are required if num is used.


  • def – definition what your new command should do.


110
newcommand example
  • \documentclass{article}
  • \newcommand{\uncg}{University of North Carolina at Greensboro}
  • \begin{document}
  • I’m a graduate student at the \uncg.
  • \end{document}
111
renewcommand & providecommand
  • The renewcommand and providecommand  have the same syntax as the newcommand except:


  • renewcommand is used to override already existing command.
  • providecommand is used if the command is already defined latex will ignore your command.
112
renewcommand example
  • \documentclass{article}


  • \renewcommand{\^} {{\diamond}}


  • \begin{document}
  • $u=abaab\^ ba$
  • \end{document}



113
Did that break ^ ?   NO!
  • \documentclass{article}
  • \renewcommand{\^} {{\diamond}}
  • \begin{document}


  • $u=abaab\^ ba$ \\
  • $a^u$ and $u^\^$ \\
  • Still works !


  • \end{document}




114
Creating your own newenvironment
  • Just as allowing you to create a new commands LaTeX also provides you ability to create your own environment using newenvironment  and renewenvironment  commands.


  • (the syntax for newenvironment and renewenvironment is the same the only difference is that renewenvironment redefines already existing environment)
115
newenvironment  and renewenvironment
  • \newenvironment{name}[args][opt]{begdef}{enddef}
  • \renewenvironment{name}[args][opt]{begdef}{enddef}
  • name – the name of your environment.
  • args – optional the number of arguments.
  • opt – optional the number of arguments required that are listed in args.
  • begdef The text substituted for every occurrence of \begin{nam}; a parameter of the form #n in begdef is replaced by the text of the nth argument when this substitution takes place.
  • enddef The text substituted for every occurrence of \end{nam}. It may not contain any argument parameters.
116
Creating your own package
  • If you created a large number of newcommands and newenvironments the preamble of your document can become quite large, to avoid this it is recommended to place your new commands and environments in a separate file and include it using the \usepackage.
117
Creating your package file
  • To create your package file place all of your new commands and environments in a separate file and save it with file extension .sty at the top of the file add \ProvidesPackage command.


  • \ProvidesPackage{name} command


  • name – specifies the name of your package it has to match the name you use with \usepackage command.
118
Bibliography
  • Wilkins, D. R.  “Summary of Commonly-Used Features of LaTeX.”  19 Nov. 1993: 1-15 p.  Online.  Internet.  22 Jan. 2006.  Available http://www.ce.chalmers.se/~thomasl/dochelp/lashort.pdf
  • Kern, Uwe.  Chroma: A Reference Book of LaTeX Colors.  4 April 2004 : n. pag.  Online.  Internet.  13 Jan. 2006.  Available http://www.ctan.org/tex- archive/documentation/colour/chroma/chroma.pdf
  • Smart, Julian.  “Commands by Category.”  Manual for Tex2RTF 2.0: A LaTeX to RTF and HTML Converter.  Nov. 1999. http://www.iriset.ac.in/man/wxwinm/tex2rtf/t2rtf28.htm#topic36 (21 Jan. 2006).
  • ---.  “LaTeX Commands.”  Manual for Tex2RTF 2.0: A LaTeX to RTF and HTML Converter.  Nov. 1999. http://www.iriset.ac.in/man/wxwinm/tex2rtf/t2rtf25.htm (21 Jan. 2006).
  • Oetiker, Tobias, et al.  The Not So Short Introduction to LaTeX 2e.  27 Sep. 2005: 1-66 p.  Online.  Internet.  11 Jan. 2006.  Available http://www.ctan.org/tex-archive/info/lshort/english/lshort.pdf
  • LaTeX 3 Project Team.  “LaTeX 2e for Authors.”  31 Jul. 2001: 11-23 p.  Online.  Internet.  20 Jan. 2006.  Available http://www.latex-project.org/guides/usrguide.pdf