Latex Liyaqat

152
Introduction to Scientific Type setting LATEX Liyaqat Nazir

Transcript of Latex Liyaqat

Page 1: Latex Liyaqat

Introduction to Scientific Type setting

LATEX

Liyaqat Nazir

An Overview

lWord Processors vs LATEXlOur First LATEX DocumentlErrorslThe Structure of a LATEX documentlDigging Beneath the SurfacelEnvironments and CommandslSymbols of Interest

Word Processors vs LATEX

bullWhatbullYoubullSeebullIs bullAll bullYou bullGet

bullWhatbullYoubullSeebullIs bullWhat bullYou bullMean

The Weaknesses of Word

lWYSIWYG programs combine composition and typesettingl most Word users donrsquot know muchl may lose logical structure of a document

lbibliographies cross-references figure labels must be completed by handldifferent versions mean compatibility issueslCostlDiscrepancies between what is seen and what is gottenlExcessive and wasteful use of processor cycles working memory and hard disk spacelProprietary formats that complicate the move to another softwarelProgram crashes and instability that are more frequent than with eg a LaTeX system and actually can cause data corruption or loss

The History of LATEX

lTEXlDonald Knuth 1978 (frozen in 1989)lfrustrated at result of Art of Computer Programminglrealized high quality digital typesetting system was necessarylLATEXlLeslie Lamport early 1980s (manual published in 1986)lneeded macro package on top of TEXlhas become the standard

lportability and compatibilitymdashtext fileslvery flexiblelIts free and Open Sourcelconsistency throughout documentlallows you to focus on contentlautomation of tedious tasks (cross-references bibliographies etc)lradical global changes can be implemented consistently with very little worklDone by mark-up Exact structure is visible and easily changeablelDealing with mathematical notation layout and entry are generally easier using lLaTeX than some other sort of equation editor lLaTeX provides very high quality and is extremely customizablelIts extremely stable no matter how complex the documents areldecision-making about formatting can be left to an expert (or not)

The Strengths of LATEX

The Weaknesses of LATEX

lFairly steep learning curvelcomplex formatting may occasionally take more time thanla word processor (eg tables)lCollaborators unfamiliar with LaTeX will have difficulty reviewing yourlmanuscriptslMany features require libraries which you have to findbe made aware lof (view changes etc)lLayout changes are difficult (ie will require time for you to hunt down lsolution and implement it)

A Simple LaTeX Document

documentclassarticle

begindocument

Hello world enddocument

bullLaTeXbullPreamble

bullBody

Class File

Defines what your document will look like First line of all LaTeX documentsSelected by documentclass commanddocumentclass[options]class_nameSome examplesamsartcls (included with basic download)documentclass[]amsartIEEEtrancls (download from [4])Specify font size number of columns format etcdocumentclass[10ptconference]IEEEtran

larticlelreportlbooklletter

lBasic Classes

Class Files - Examples

Macro Packages

lPreamble area is use for document formatting purposelAll the packages needed to format the document are defined in this area of latex documentlAllow you to use special commandslPackages are activated byusepackage[options]package_nameExamples

bull citesty bull usepackagecite

bull graphicxsty bull usepackagegraphicx

bull geometrysty bull usepackage[margin=1in]geometry

bull urlsty bull usepackageurl

A Quick Review

bullLaTeX

writing special characters in our text

The following symbols are reserved $ amp _ ^ ~ To include them in your text $ amp _ ^ ~ Note you cannot just do (which is a linebreak) but instead$backslash$ or textbackslash

The Font Size Option

All of LATEXrsquos font size adjustments are set based upon the normalsize for the document1 The default text size for a document is 10 point2 To make a change use an optional argument on thedocumentclass commanddocumentclass[12pt]article

3 Permitted font sizes for the article class 9 10 11 12

Changing SizesFrom smallest to largest

CommandtinyscriptsizefootnotesizesmallnormalsizelargeLargeLARGEhugeHuge

bullOptional argument

Formatting text ndash fonts shapes and styles

Making words appear bold italic or slantedhow to highlight words in a part of some text thats already emphasized

Commandsemphused to put emphasis on a textGeneral Format of text formatting commands textargumentWhere is ldquobfrdquo for bold font ldquoitrdquo for ittallic ldquoslrdquo for Slanted ldquosfrdquo for San-serif font ldquottrdquo for Type-writer font

Two Examples

An example of changing font sizes within a documenttype These large words Large get LARGE big

see These words get bigAnother exampletype Lots huge of differentsmall sizes tiny of normalsize textsee Lotsof different sizes of text

Changing colors for soul

You can change the strikethrough highlighting and underlineusepackagesoulstHellow worldColorssetstcolorred Makes the strikethrough redsethlcolorgreen Makes the highlight color greensetulcolororange Makes the underline color orange

$X^2$ --Superscript$X_2$ -- Subscript

Text Justification

Environments are necessary to change the standard full justificationthat LATEX uses

Environment EffectCenter Centered textFlushright Right justificationFlushleft Left justification

ExampledocumentclassarticlebegindocumentbegincenterHello worldendcenterenddocument

Other waysraggedright justifies text to rightraggedleft justifies text to leftcenteringtext justifies text to center

creating a narrow text column amp word divisions

Sometimes wed like a paragraph to have a smaller width we would like to put text and a picture side-by-side

parbox[alignment][Hcm][inner alignment]Wcmtext inside column to creates a column Of width W cmOf height Hcm

documentclassarticlebegindocumentparbox3cmTUG is an acronym It means TeX Users Groupenddocument

lhyphenationacro-nym---gt states division points for wordsluserdquousepackage[none]hyphenatrdquolusepackage[htt]hyphenat- enables hyphens

lInner alignmentlcmdashvertically center the text in the boxltmdashplace text at the top of the boxlbmdashplace text at its bottomlsmdashstretch the text vertically if possible

Paragraph Boxes

The text within a paragraph boxworks just like a paragraph exceptthat the author sets thewidthparbox2inThe text within sets the widthYou can accomplish the same thing with the minipageenvironment

Syntaxparboxwidthtext

beginminipagewidthtext

endminipage

Accents and Ellipses

AccentsIf you need accented characters like from a different languageyoursquoll need some special commands

Ellipsestype It was the best of times dotssee It was the best of times

using accents directly

Use package inputenc

Exampledocumentclassarticleusepackage[utf8]inputencbegindocumentNatildeo compreendo Haacute aqui algueacutem que fale inglecircsComment ccedilava Ougrave se trouve laeacuteroportenddocument

inputenc package The option utf8 tells the package to use Unicode inputencoding which provides many more symbols than just the ASCII code

Units of the Document(Breaking Lines)

There are three ways to get a new line of text1 Insert a blank line in the tex file This produces a newparagraph2 Use the command Text after the double backslash willappear on the next line without any indentation (Make sureyou have a space in the tex file after the to achieve this)3 Use newline This functions the same way as Most prefer because of this added functionality

Command Effect[length] creates interline space of length prevents page break after line[length] combination

nolinebreak[length] This command prevents a line break at the current position

An Example

TypeI think we should continuethis conversation [3in] down here

See

I think we should continue this conversation

down hereAcceptable units of measurement in cm pt

Breaking Paragraphs

lWersquove seen that a blank line in your file produces a new paragraphlwe might not want this paragraph indented (It is indented by default)lUse the command noindent before the first line of the next paragraph

documentclassarticlebegindocumentThis is indentednoindent This is notenddocument

Insert the following line into the preamble hyphenationacro-nym tells latex that word acronym has to be hyphenatedhyphenationacronym or mboxacronym will prevent hyphenation of acronymmboxtext will also prevent a line break for the complete text

Spacing in Paragraphs

to distinguish paragraphs there are two common wayslindent thebeginning of each paragraph(default latex syle)lto insert vertical space between paragraphs while omitting the indentation (suitable for narrow columns where indenting would cost too much width)

Load the parskip packagelremoves the paragraph indentation completelyl Introduces a skip between paragraphs

documentclassarticleusepackageparskipusepackageurlbegindocumentThe authors of the CTAN team listed ten good reasonsfor using TeX Among them areTeX has the best output ldotsThe original text can be found onurl httpwwwctanorgwhat_is_texhtmlenddocument

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 2: Latex Liyaqat

An Overview

lWord Processors vs LATEXlOur First LATEX DocumentlErrorslThe Structure of a LATEX documentlDigging Beneath the SurfacelEnvironments and CommandslSymbols of Interest

Word Processors vs LATEX

bullWhatbullYoubullSeebullIs bullAll bullYou bullGet

bullWhatbullYoubullSeebullIs bullWhat bullYou bullMean

The Weaknesses of Word

lWYSIWYG programs combine composition and typesettingl most Word users donrsquot know muchl may lose logical structure of a document

lbibliographies cross-references figure labels must be completed by handldifferent versions mean compatibility issueslCostlDiscrepancies between what is seen and what is gottenlExcessive and wasteful use of processor cycles working memory and hard disk spacelProprietary formats that complicate the move to another softwarelProgram crashes and instability that are more frequent than with eg a LaTeX system and actually can cause data corruption or loss

The History of LATEX

lTEXlDonald Knuth 1978 (frozen in 1989)lfrustrated at result of Art of Computer Programminglrealized high quality digital typesetting system was necessarylLATEXlLeslie Lamport early 1980s (manual published in 1986)lneeded macro package on top of TEXlhas become the standard

lportability and compatibilitymdashtext fileslvery flexiblelIts free and Open Sourcelconsistency throughout documentlallows you to focus on contentlautomation of tedious tasks (cross-references bibliographies etc)lradical global changes can be implemented consistently with very little worklDone by mark-up Exact structure is visible and easily changeablelDealing with mathematical notation layout and entry are generally easier using lLaTeX than some other sort of equation editor lLaTeX provides very high quality and is extremely customizablelIts extremely stable no matter how complex the documents areldecision-making about formatting can be left to an expert (or not)

The Strengths of LATEX

The Weaknesses of LATEX

lFairly steep learning curvelcomplex formatting may occasionally take more time thanla word processor (eg tables)lCollaborators unfamiliar with LaTeX will have difficulty reviewing yourlmanuscriptslMany features require libraries which you have to findbe made aware lof (view changes etc)lLayout changes are difficult (ie will require time for you to hunt down lsolution and implement it)

A Simple LaTeX Document

documentclassarticle

begindocument

Hello world enddocument

bullLaTeXbullPreamble

bullBody

Class File

Defines what your document will look like First line of all LaTeX documentsSelected by documentclass commanddocumentclass[options]class_nameSome examplesamsartcls (included with basic download)documentclass[]amsartIEEEtrancls (download from [4])Specify font size number of columns format etcdocumentclass[10ptconference]IEEEtran

larticlelreportlbooklletter

lBasic Classes

Class Files - Examples

Macro Packages

lPreamble area is use for document formatting purposelAll the packages needed to format the document are defined in this area of latex documentlAllow you to use special commandslPackages are activated byusepackage[options]package_nameExamples

bull citesty bull usepackagecite

bull graphicxsty bull usepackagegraphicx

bull geometrysty bull usepackage[margin=1in]geometry

bull urlsty bull usepackageurl

A Quick Review

bullLaTeX

writing special characters in our text

The following symbols are reserved $ amp _ ^ ~ To include them in your text $ amp _ ^ ~ Note you cannot just do (which is a linebreak) but instead$backslash$ or textbackslash

The Font Size Option

All of LATEXrsquos font size adjustments are set based upon the normalsize for the document1 The default text size for a document is 10 point2 To make a change use an optional argument on thedocumentclass commanddocumentclass[12pt]article

3 Permitted font sizes for the article class 9 10 11 12

Changing SizesFrom smallest to largest

CommandtinyscriptsizefootnotesizesmallnormalsizelargeLargeLARGEhugeHuge

bullOptional argument

Formatting text ndash fonts shapes and styles

Making words appear bold italic or slantedhow to highlight words in a part of some text thats already emphasized

Commandsemphused to put emphasis on a textGeneral Format of text formatting commands textargumentWhere is ldquobfrdquo for bold font ldquoitrdquo for ittallic ldquoslrdquo for Slanted ldquosfrdquo for San-serif font ldquottrdquo for Type-writer font

Two Examples

An example of changing font sizes within a documenttype These large words Large get LARGE big

see These words get bigAnother exampletype Lots huge of differentsmall sizes tiny of normalsize textsee Lotsof different sizes of text

Changing colors for soul

You can change the strikethrough highlighting and underlineusepackagesoulstHellow worldColorssetstcolorred Makes the strikethrough redsethlcolorgreen Makes the highlight color greensetulcolororange Makes the underline color orange

$X^2$ --Superscript$X_2$ -- Subscript

Text Justification

Environments are necessary to change the standard full justificationthat LATEX uses

Environment EffectCenter Centered textFlushright Right justificationFlushleft Left justification

ExampledocumentclassarticlebegindocumentbegincenterHello worldendcenterenddocument

Other waysraggedright justifies text to rightraggedleft justifies text to leftcenteringtext justifies text to center

creating a narrow text column amp word divisions

Sometimes wed like a paragraph to have a smaller width we would like to put text and a picture side-by-side

parbox[alignment][Hcm][inner alignment]Wcmtext inside column to creates a column Of width W cmOf height Hcm

documentclassarticlebegindocumentparbox3cmTUG is an acronym It means TeX Users Groupenddocument

lhyphenationacro-nym---gt states division points for wordsluserdquousepackage[none]hyphenatrdquolusepackage[htt]hyphenat- enables hyphens

lInner alignmentlcmdashvertically center the text in the boxltmdashplace text at the top of the boxlbmdashplace text at its bottomlsmdashstretch the text vertically if possible

Paragraph Boxes

The text within a paragraph boxworks just like a paragraph exceptthat the author sets thewidthparbox2inThe text within sets the widthYou can accomplish the same thing with the minipageenvironment

Syntaxparboxwidthtext

beginminipagewidthtext

endminipage

Accents and Ellipses

AccentsIf you need accented characters like from a different languageyoursquoll need some special commands

Ellipsestype It was the best of times dotssee It was the best of times

using accents directly

Use package inputenc

Exampledocumentclassarticleusepackage[utf8]inputencbegindocumentNatildeo compreendo Haacute aqui algueacutem que fale inglecircsComment ccedilava Ougrave se trouve laeacuteroportenddocument

inputenc package The option utf8 tells the package to use Unicode inputencoding which provides many more symbols than just the ASCII code

Units of the Document(Breaking Lines)

There are three ways to get a new line of text1 Insert a blank line in the tex file This produces a newparagraph2 Use the command Text after the double backslash willappear on the next line without any indentation (Make sureyou have a space in the tex file after the to achieve this)3 Use newline This functions the same way as Most prefer because of this added functionality

Command Effect[length] creates interline space of length prevents page break after line[length] combination

nolinebreak[length] This command prevents a line break at the current position

An Example

TypeI think we should continuethis conversation [3in] down here

See

I think we should continue this conversation

down hereAcceptable units of measurement in cm pt

Breaking Paragraphs

lWersquove seen that a blank line in your file produces a new paragraphlwe might not want this paragraph indented (It is indented by default)lUse the command noindent before the first line of the next paragraph

documentclassarticlebegindocumentThis is indentednoindent This is notenddocument

Insert the following line into the preamble hyphenationacro-nym tells latex that word acronym has to be hyphenatedhyphenationacronym or mboxacronym will prevent hyphenation of acronymmboxtext will also prevent a line break for the complete text

Spacing in Paragraphs

to distinguish paragraphs there are two common wayslindent thebeginning of each paragraph(default latex syle)lto insert vertical space between paragraphs while omitting the indentation (suitable for narrow columns where indenting would cost too much width)

Load the parskip packagelremoves the paragraph indentation completelyl Introduces a skip between paragraphs

documentclassarticleusepackageparskipusepackageurlbegindocumentThe authors of the CTAN team listed ten good reasonsfor using TeX Among them areTeX has the best output ldotsThe original text can be found onurl httpwwwctanorgwhat_is_texhtmlenddocument

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 3: Latex Liyaqat

Word Processors vs LATEX

bullWhatbullYoubullSeebullIs bullAll bullYou bullGet

bullWhatbullYoubullSeebullIs bullWhat bullYou bullMean

The Weaknesses of Word

lWYSIWYG programs combine composition and typesettingl most Word users donrsquot know muchl may lose logical structure of a document

lbibliographies cross-references figure labels must be completed by handldifferent versions mean compatibility issueslCostlDiscrepancies between what is seen and what is gottenlExcessive and wasteful use of processor cycles working memory and hard disk spacelProprietary formats that complicate the move to another softwarelProgram crashes and instability that are more frequent than with eg a LaTeX system and actually can cause data corruption or loss

The History of LATEX

lTEXlDonald Knuth 1978 (frozen in 1989)lfrustrated at result of Art of Computer Programminglrealized high quality digital typesetting system was necessarylLATEXlLeslie Lamport early 1980s (manual published in 1986)lneeded macro package on top of TEXlhas become the standard

lportability and compatibilitymdashtext fileslvery flexiblelIts free and Open Sourcelconsistency throughout documentlallows you to focus on contentlautomation of tedious tasks (cross-references bibliographies etc)lradical global changes can be implemented consistently with very little worklDone by mark-up Exact structure is visible and easily changeablelDealing with mathematical notation layout and entry are generally easier using lLaTeX than some other sort of equation editor lLaTeX provides very high quality and is extremely customizablelIts extremely stable no matter how complex the documents areldecision-making about formatting can be left to an expert (or not)

The Strengths of LATEX

The Weaknesses of LATEX

lFairly steep learning curvelcomplex formatting may occasionally take more time thanla word processor (eg tables)lCollaborators unfamiliar with LaTeX will have difficulty reviewing yourlmanuscriptslMany features require libraries which you have to findbe made aware lof (view changes etc)lLayout changes are difficult (ie will require time for you to hunt down lsolution and implement it)

A Simple LaTeX Document

documentclassarticle

begindocument

Hello world enddocument

bullLaTeXbullPreamble

bullBody

Class File

Defines what your document will look like First line of all LaTeX documentsSelected by documentclass commanddocumentclass[options]class_nameSome examplesamsartcls (included with basic download)documentclass[]amsartIEEEtrancls (download from [4])Specify font size number of columns format etcdocumentclass[10ptconference]IEEEtran

larticlelreportlbooklletter

lBasic Classes

Class Files - Examples

Macro Packages

lPreamble area is use for document formatting purposelAll the packages needed to format the document are defined in this area of latex documentlAllow you to use special commandslPackages are activated byusepackage[options]package_nameExamples

bull citesty bull usepackagecite

bull graphicxsty bull usepackagegraphicx

bull geometrysty bull usepackage[margin=1in]geometry

bull urlsty bull usepackageurl

A Quick Review

bullLaTeX

writing special characters in our text

The following symbols are reserved $ amp _ ^ ~ To include them in your text $ amp _ ^ ~ Note you cannot just do (which is a linebreak) but instead$backslash$ or textbackslash

The Font Size Option

All of LATEXrsquos font size adjustments are set based upon the normalsize for the document1 The default text size for a document is 10 point2 To make a change use an optional argument on thedocumentclass commanddocumentclass[12pt]article

3 Permitted font sizes for the article class 9 10 11 12

Changing SizesFrom smallest to largest

CommandtinyscriptsizefootnotesizesmallnormalsizelargeLargeLARGEhugeHuge

bullOptional argument

Formatting text ndash fonts shapes and styles

Making words appear bold italic or slantedhow to highlight words in a part of some text thats already emphasized

Commandsemphused to put emphasis on a textGeneral Format of text formatting commands textargumentWhere is ldquobfrdquo for bold font ldquoitrdquo for ittallic ldquoslrdquo for Slanted ldquosfrdquo for San-serif font ldquottrdquo for Type-writer font

Two Examples

An example of changing font sizes within a documenttype These large words Large get LARGE big

see These words get bigAnother exampletype Lots huge of differentsmall sizes tiny of normalsize textsee Lotsof different sizes of text

Changing colors for soul

You can change the strikethrough highlighting and underlineusepackagesoulstHellow worldColorssetstcolorred Makes the strikethrough redsethlcolorgreen Makes the highlight color greensetulcolororange Makes the underline color orange

$X^2$ --Superscript$X_2$ -- Subscript

Text Justification

Environments are necessary to change the standard full justificationthat LATEX uses

Environment EffectCenter Centered textFlushright Right justificationFlushleft Left justification

ExampledocumentclassarticlebegindocumentbegincenterHello worldendcenterenddocument

Other waysraggedright justifies text to rightraggedleft justifies text to leftcenteringtext justifies text to center

creating a narrow text column amp word divisions

Sometimes wed like a paragraph to have a smaller width we would like to put text and a picture side-by-side

parbox[alignment][Hcm][inner alignment]Wcmtext inside column to creates a column Of width W cmOf height Hcm

documentclassarticlebegindocumentparbox3cmTUG is an acronym It means TeX Users Groupenddocument

lhyphenationacro-nym---gt states division points for wordsluserdquousepackage[none]hyphenatrdquolusepackage[htt]hyphenat- enables hyphens

lInner alignmentlcmdashvertically center the text in the boxltmdashplace text at the top of the boxlbmdashplace text at its bottomlsmdashstretch the text vertically if possible

Paragraph Boxes

The text within a paragraph boxworks just like a paragraph exceptthat the author sets thewidthparbox2inThe text within sets the widthYou can accomplish the same thing with the minipageenvironment

Syntaxparboxwidthtext

beginminipagewidthtext

endminipage

Accents and Ellipses

AccentsIf you need accented characters like from a different languageyoursquoll need some special commands

Ellipsestype It was the best of times dotssee It was the best of times

using accents directly

Use package inputenc

Exampledocumentclassarticleusepackage[utf8]inputencbegindocumentNatildeo compreendo Haacute aqui algueacutem que fale inglecircsComment ccedilava Ougrave se trouve laeacuteroportenddocument

inputenc package The option utf8 tells the package to use Unicode inputencoding which provides many more symbols than just the ASCII code

Units of the Document(Breaking Lines)

There are three ways to get a new line of text1 Insert a blank line in the tex file This produces a newparagraph2 Use the command Text after the double backslash willappear on the next line without any indentation (Make sureyou have a space in the tex file after the to achieve this)3 Use newline This functions the same way as Most prefer because of this added functionality

Command Effect[length] creates interline space of length prevents page break after line[length] combination

nolinebreak[length] This command prevents a line break at the current position

An Example

TypeI think we should continuethis conversation [3in] down here

See

I think we should continue this conversation

down hereAcceptable units of measurement in cm pt

Breaking Paragraphs

lWersquove seen that a blank line in your file produces a new paragraphlwe might not want this paragraph indented (It is indented by default)lUse the command noindent before the first line of the next paragraph

documentclassarticlebegindocumentThis is indentednoindent This is notenddocument

Insert the following line into the preamble hyphenationacro-nym tells latex that word acronym has to be hyphenatedhyphenationacronym or mboxacronym will prevent hyphenation of acronymmboxtext will also prevent a line break for the complete text

Spacing in Paragraphs

to distinguish paragraphs there are two common wayslindent thebeginning of each paragraph(default latex syle)lto insert vertical space between paragraphs while omitting the indentation (suitable for narrow columns where indenting would cost too much width)

Load the parskip packagelremoves the paragraph indentation completelyl Introduces a skip between paragraphs

documentclassarticleusepackageparskipusepackageurlbegindocumentThe authors of the CTAN team listed ten good reasonsfor using TeX Among them areTeX has the best output ldotsThe original text can be found onurl httpwwwctanorgwhat_is_texhtmlenddocument

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 4: Latex Liyaqat

The Weaknesses of Word

lWYSIWYG programs combine composition and typesettingl most Word users donrsquot know muchl may lose logical structure of a document

lbibliographies cross-references figure labels must be completed by handldifferent versions mean compatibility issueslCostlDiscrepancies between what is seen and what is gottenlExcessive and wasteful use of processor cycles working memory and hard disk spacelProprietary formats that complicate the move to another softwarelProgram crashes and instability that are more frequent than with eg a LaTeX system and actually can cause data corruption or loss

The History of LATEX

lTEXlDonald Knuth 1978 (frozen in 1989)lfrustrated at result of Art of Computer Programminglrealized high quality digital typesetting system was necessarylLATEXlLeslie Lamport early 1980s (manual published in 1986)lneeded macro package on top of TEXlhas become the standard

lportability and compatibilitymdashtext fileslvery flexiblelIts free and Open Sourcelconsistency throughout documentlallows you to focus on contentlautomation of tedious tasks (cross-references bibliographies etc)lradical global changes can be implemented consistently with very little worklDone by mark-up Exact structure is visible and easily changeablelDealing with mathematical notation layout and entry are generally easier using lLaTeX than some other sort of equation editor lLaTeX provides very high quality and is extremely customizablelIts extremely stable no matter how complex the documents areldecision-making about formatting can be left to an expert (or not)

The Strengths of LATEX

The Weaknesses of LATEX

lFairly steep learning curvelcomplex formatting may occasionally take more time thanla word processor (eg tables)lCollaborators unfamiliar with LaTeX will have difficulty reviewing yourlmanuscriptslMany features require libraries which you have to findbe made aware lof (view changes etc)lLayout changes are difficult (ie will require time for you to hunt down lsolution and implement it)

A Simple LaTeX Document

documentclassarticle

begindocument

Hello world enddocument

bullLaTeXbullPreamble

bullBody

Class File

Defines what your document will look like First line of all LaTeX documentsSelected by documentclass commanddocumentclass[options]class_nameSome examplesamsartcls (included with basic download)documentclass[]amsartIEEEtrancls (download from [4])Specify font size number of columns format etcdocumentclass[10ptconference]IEEEtran

larticlelreportlbooklletter

lBasic Classes

Class Files - Examples

Macro Packages

lPreamble area is use for document formatting purposelAll the packages needed to format the document are defined in this area of latex documentlAllow you to use special commandslPackages are activated byusepackage[options]package_nameExamples

bull citesty bull usepackagecite

bull graphicxsty bull usepackagegraphicx

bull geometrysty bull usepackage[margin=1in]geometry

bull urlsty bull usepackageurl

A Quick Review

bullLaTeX

writing special characters in our text

The following symbols are reserved $ amp _ ^ ~ To include them in your text $ amp _ ^ ~ Note you cannot just do (which is a linebreak) but instead$backslash$ or textbackslash

The Font Size Option

All of LATEXrsquos font size adjustments are set based upon the normalsize for the document1 The default text size for a document is 10 point2 To make a change use an optional argument on thedocumentclass commanddocumentclass[12pt]article

3 Permitted font sizes for the article class 9 10 11 12

Changing SizesFrom smallest to largest

CommandtinyscriptsizefootnotesizesmallnormalsizelargeLargeLARGEhugeHuge

bullOptional argument

Formatting text ndash fonts shapes and styles

Making words appear bold italic or slantedhow to highlight words in a part of some text thats already emphasized

Commandsemphused to put emphasis on a textGeneral Format of text formatting commands textargumentWhere is ldquobfrdquo for bold font ldquoitrdquo for ittallic ldquoslrdquo for Slanted ldquosfrdquo for San-serif font ldquottrdquo for Type-writer font

Two Examples

An example of changing font sizes within a documenttype These large words Large get LARGE big

see These words get bigAnother exampletype Lots huge of differentsmall sizes tiny of normalsize textsee Lotsof different sizes of text

Changing colors for soul

You can change the strikethrough highlighting and underlineusepackagesoulstHellow worldColorssetstcolorred Makes the strikethrough redsethlcolorgreen Makes the highlight color greensetulcolororange Makes the underline color orange

$X^2$ --Superscript$X_2$ -- Subscript

Text Justification

Environments are necessary to change the standard full justificationthat LATEX uses

Environment EffectCenter Centered textFlushright Right justificationFlushleft Left justification

ExampledocumentclassarticlebegindocumentbegincenterHello worldendcenterenddocument

Other waysraggedright justifies text to rightraggedleft justifies text to leftcenteringtext justifies text to center

creating a narrow text column amp word divisions

Sometimes wed like a paragraph to have a smaller width we would like to put text and a picture side-by-side

parbox[alignment][Hcm][inner alignment]Wcmtext inside column to creates a column Of width W cmOf height Hcm

documentclassarticlebegindocumentparbox3cmTUG is an acronym It means TeX Users Groupenddocument

lhyphenationacro-nym---gt states division points for wordsluserdquousepackage[none]hyphenatrdquolusepackage[htt]hyphenat- enables hyphens

lInner alignmentlcmdashvertically center the text in the boxltmdashplace text at the top of the boxlbmdashplace text at its bottomlsmdashstretch the text vertically if possible

Paragraph Boxes

The text within a paragraph boxworks just like a paragraph exceptthat the author sets thewidthparbox2inThe text within sets the widthYou can accomplish the same thing with the minipageenvironment

Syntaxparboxwidthtext

beginminipagewidthtext

endminipage

Accents and Ellipses

AccentsIf you need accented characters like from a different languageyoursquoll need some special commands

Ellipsestype It was the best of times dotssee It was the best of times

using accents directly

Use package inputenc

Exampledocumentclassarticleusepackage[utf8]inputencbegindocumentNatildeo compreendo Haacute aqui algueacutem que fale inglecircsComment ccedilava Ougrave se trouve laeacuteroportenddocument

inputenc package The option utf8 tells the package to use Unicode inputencoding which provides many more symbols than just the ASCII code

Units of the Document(Breaking Lines)

There are three ways to get a new line of text1 Insert a blank line in the tex file This produces a newparagraph2 Use the command Text after the double backslash willappear on the next line without any indentation (Make sureyou have a space in the tex file after the to achieve this)3 Use newline This functions the same way as Most prefer because of this added functionality

Command Effect[length] creates interline space of length prevents page break after line[length] combination

nolinebreak[length] This command prevents a line break at the current position

An Example

TypeI think we should continuethis conversation [3in] down here

See

I think we should continue this conversation

down hereAcceptable units of measurement in cm pt

Breaking Paragraphs

lWersquove seen that a blank line in your file produces a new paragraphlwe might not want this paragraph indented (It is indented by default)lUse the command noindent before the first line of the next paragraph

documentclassarticlebegindocumentThis is indentednoindent This is notenddocument

Insert the following line into the preamble hyphenationacro-nym tells latex that word acronym has to be hyphenatedhyphenationacronym or mboxacronym will prevent hyphenation of acronymmboxtext will also prevent a line break for the complete text

Spacing in Paragraphs

to distinguish paragraphs there are two common wayslindent thebeginning of each paragraph(default latex syle)lto insert vertical space between paragraphs while omitting the indentation (suitable for narrow columns where indenting would cost too much width)

Load the parskip packagelremoves the paragraph indentation completelyl Introduces a skip between paragraphs

documentclassarticleusepackageparskipusepackageurlbegindocumentThe authors of the CTAN team listed ten good reasonsfor using TeX Among them areTeX has the best output ldotsThe original text can be found onurl httpwwwctanorgwhat_is_texhtmlenddocument

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 5: Latex Liyaqat

The History of LATEX

lTEXlDonald Knuth 1978 (frozen in 1989)lfrustrated at result of Art of Computer Programminglrealized high quality digital typesetting system was necessarylLATEXlLeslie Lamport early 1980s (manual published in 1986)lneeded macro package on top of TEXlhas become the standard

lportability and compatibilitymdashtext fileslvery flexiblelIts free and Open Sourcelconsistency throughout documentlallows you to focus on contentlautomation of tedious tasks (cross-references bibliographies etc)lradical global changes can be implemented consistently with very little worklDone by mark-up Exact structure is visible and easily changeablelDealing with mathematical notation layout and entry are generally easier using lLaTeX than some other sort of equation editor lLaTeX provides very high quality and is extremely customizablelIts extremely stable no matter how complex the documents areldecision-making about formatting can be left to an expert (or not)

The Strengths of LATEX

The Weaknesses of LATEX

lFairly steep learning curvelcomplex formatting may occasionally take more time thanla word processor (eg tables)lCollaborators unfamiliar with LaTeX will have difficulty reviewing yourlmanuscriptslMany features require libraries which you have to findbe made aware lof (view changes etc)lLayout changes are difficult (ie will require time for you to hunt down lsolution and implement it)

A Simple LaTeX Document

documentclassarticle

begindocument

Hello world enddocument

bullLaTeXbullPreamble

bullBody

Class File

Defines what your document will look like First line of all LaTeX documentsSelected by documentclass commanddocumentclass[options]class_nameSome examplesamsartcls (included with basic download)documentclass[]amsartIEEEtrancls (download from [4])Specify font size number of columns format etcdocumentclass[10ptconference]IEEEtran

larticlelreportlbooklletter

lBasic Classes

Class Files - Examples

Macro Packages

lPreamble area is use for document formatting purposelAll the packages needed to format the document are defined in this area of latex documentlAllow you to use special commandslPackages are activated byusepackage[options]package_nameExamples

bull citesty bull usepackagecite

bull graphicxsty bull usepackagegraphicx

bull geometrysty bull usepackage[margin=1in]geometry

bull urlsty bull usepackageurl

A Quick Review

bullLaTeX

writing special characters in our text

The following symbols are reserved $ amp _ ^ ~ To include them in your text $ amp _ ^ ~ Note you cannot just do (which is a linebreak) but instead$backslash$ or textbackslash

The Font Size Option

All of LATEXrsquos font size adjustments are set based upon the normalsize for the document1 The default text size for a document is 10 point2 To make a change use an optional argument on thedocumentclass commanddocumentclass[12pt]article

3 Permitted font sizes for the article class 9 10 11 12

Changing SizesFrom smallest to largest

CommandtinyscriptsizefootnotesizesmallnormalsizelargeLargeLARGEhugeHuge

bullOptional argument

Formatting text ndash fonts shapes and styles

Making words appear bold italic or slantedhow to highlight words in a part of some text thats already emphasized

Commandsemphused to put emphasis on a textGeneral Format of text formatting commands textargumentWhere is ldquobfrdquo for bold font ldquoitrdquo for ittallic ldquoslrdquo for Slanted ldquosfrdquo for San-serif font ldquottrdquo for Type-writer font

Two Examples

An example of changing font sizes within a documenttype These large words Large get LARGE big

see These words get bigAnother exampletype Lots huge of differentsmall sizes tiny of normalsize textsee Lotsof different sizes of text

Changing colors for soul

You can change the strikethrough highlighting and underlineusepackagesoulstHellow worldColorssetstcolorred Makes the strikethrough redsethlcolorgreen Makes the highlight color greensetulcolororange Makes the underline color orange

$X^2$ --Superscript$X_2$ -- Subscript

Text Justification

Environments are necessary to change the standard full justificationthat LATEX uses

Environment EffectCenter Centered textFlushright Right justificationFlushleft Left justification

ExampledocumentclassarticlebegindocumentbegincenterHello worldendcenterenddocument

Other waysraggedright justifies text to rightraggedleft justifies text to leftcenteringtext justifies text to center

creating a narrow text column amp word divisions

Sometimes wed like a paragraph to have a smaller width we would like to put text and a picture side-by-side

parbox[alignment][Hcm][inner alignment]Wcmtext inside column to creates a column Of width W cmOf height Hcm

documentclassarticlebegindocumentparbox3cmTUG is an acronym It means TeX Users Groupenddocument

lhyphenationacro-nym---gt states division points for wordsluserdquousepackage[none]hyphenatrdquolusepackage[htt]hyphenat- enables hyphens

lInner alignmentlcmdashvertically center the text in the boxltmdashplace text at the top of the boxlbmdashplace text at its bottomlsmdashstretch the text vertically if possible

Paragraph Boxes

The text within a paragraph boxworks just like a paragraph exceptthat the author sets thewidthparbox2inThe text within sets the widthYou can accomplish the same thing with the minipageenvironment

Syntaxparboxwidthtext

beginminipagewidthtext

endminipage

Accents and Ellipses

AccentsIf you need accented characters like from a different languageyoursquoll need some special commands

Ellipsestype It was the best of times dotssee It was the best of times

using accents directly

Use package inputenc

Exampledocumentclassarticleusepackage[utf8]inputencbegindocumentNatildeo compreendo Haacute aqui algueacutem que fale inglecircsComment ccedilava Ougrave se trouve laeacuteroportenddocument

inputenc package The option utf8 tells the package to use Unicode inputencoding which provides many more symbols than just the ASCII code

Units of the Document(Breaking Lines)

There are three ways to get a new line of text1 Insert a blank line in the tex file This produces a newparagraph2 Use the command Text after the double backslash willappear on the next line without any indentation (Make sureyou have a space in the tex file after the to achieve this)3 Use newline This functions the same way as Most prefer because of this added functionality

Command Effect[length] creates interline space of length prevents page break after line[length] combination

nolinebreak[length] This command prevents a line break at the current position

An Example

TypeI think we should continuethis conversation [3in] down here

See

I think we should continue this conversation

down hereAcceptable units of measurement in cm pt

Breaking Paragraphs

lWersquove seen that a blank line in your file produces a new paragraphlwe might not want this paragraph indented (It is indented by default)lUse the command noindent before the first line of the next paragraph

documentclassarticlebegindocumentThis is indentednoindent This is notenddocument

Insert the following line into the preamble hyphenationacro-nym tells latex that word acronym has to be hyphenatedhyphenationacronym or mboxacronym will prevent hyphenation of acronymmboxtext will also prevent a line break for the complete text

Spacing in Paragraphs

to distinguish paragraphs there are two common wayslindent thebeginning of each paragraph(default latex syle)lto insert vertical space between paragraphs while omitting the indentation (suitable for narrow columns where indenting would cost too much width)

Load the parskip packagelremoves the paragraph indentation completelyl Introduces a skip between paragraphs

documentclassarticleusepackageparskipusepackageurlbegindocumentThe authors of the CTAN team listed ten good reasonsfor using TeX Among them areTeX has the best output ldotsThe original text can be found onurl httpwwwctanorgwhat_is_texhtmlenddocument

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 6: Latex Liyaqat

lportability and compatibilitymdashtext fileslvery flexiblelIts free and Open Sourcelconsistency throughout documentlallows you to focus on contentlautomation of tedious tasks (cross-references bibliographies etc)lradical global changes can be implemented consistently with very little worklDone by mark-up Exact structure is visible and easily changeablelDealing with mathematical notation layout and entry are generally easier using lLaTeX than some other sort of equation editor lLaTeX provides very high quality and is extremely customizablelIts extremely stable no matter how complex the documents areldecision-making about formatting can be left to an expert (or not)

The Strengths of LATEX

The Weaknesses of LATEX

lFairly steep learning curvelcomplex formatting may occasionally take more time thanla word processor (eg tables)lCollaborators unfamiliar with LaTeX will have difficulty reviewing yourlmanuscriptslMany features require libraries which you have to findbe made aware lof (view changes etc)lLayout changes are difficult (ie will require time for you to hunt down lsolution and implement it)

A Simple LaTeX Document

documentclassarticle

begindocument

Hello world enddocument

bullLaTeXbullPreamble

bullBody

Class File

Defines what your document will look like First line of all LaTeX documentsSelected by documentclass commanddocumentclass[options]class_nameSome examplesamsartcls (included with basic download)documentclass[]amsartIEEEtrancls (download from [4])Specify font size number of columns format etcdocumentclass[10ptconference]IEEEtran

larticlelreportlbooklletter

lBasic Classes

Class Files - Examples

Macro Packages

lPreamble area is use for document formatting purposelAll the packages needed to format the document are defined in this area of latex documentlAllow you to use special commandslPackages are activated byusepackage[options]package_nameExamples

bull citesty bull usepackagecite

bull graphicxsty bull usepackagegraphicx

bull geometrysty bull usepackage[margin=1in]geometry

bull urlsty bull usepackageurl

A Quick Review

bullLaTeX

writing special characters in our text

The following symbols are reserved $ amp _ ^ ~ To include them in your text $ amp _ ^ ~ Note you cannot just do (which is a linebreak) but instead$backslash$ or textbackslash

The Font Size Option

All of LATEXrsquos font size adjustments are set based upon the normalsize for the document1 The default text size for a document is 10 point2 To make a change use an optional argument on thedocumentclass commanddocumentclass[12pt]article

3 Permitted font sizes for the article class 9 10 11 12

Changing SizesFrom smallest to largest

CommandtinyscriptsizefootnotesizesmallnormalsizelargeLargeLARGEhugeHuge

bullOptional argument

Formatting text ndash fonts shapes and styles

Making words appear bold italic or slantedhow to highlight words in a part of some text thats already emphasized

Commandsemphused to put emphasis on a textGeneral Format of text formatting commands textargumentWhere is ldquobfrdquo for bold font ldquoitrdquo for ittallic ldquoslrdquo for Slanted ldquosfrdquo for San-serif font ldquottrdquo for Type-writer font

Two Examples

An example of changing font sizes within a documenttype These large words Large get LARGE big

see These words get bigAnother exampletype Lots huge of differentsmall sizes tiny of normalsize textsee Lotsof different sizes of text

Changing colors for soul

You can change the strikethrough highlighting and underlineusepackagesoulstHellow worldColorssetstcolorred Makes the strikethrough redsethlcolorgreen Makes the highlight color greensetulcolororange Makes the underline color orange

$X^2$ --Superscript$X_2$ -- Subscript

Text Justification

Environments are necessary to change the standard full justificationthat LATEX uses

Environment EffectCenter Centered textFlushright Right justificationFlushleft Left justification

ExampledocumentclassarticlebegindocumentbegincenterHello worldendcenterenddocument

Other waysraggedright justifies text to rightraggedleft justifies text to leftcenteringtext justifies text to center

creating a narrow text column amp word divisions

Sometimes wed like a paragraph to have a smaller width we would like to put text and a picture side-by-side

parbox[alignment][Hcm][inner alignment]Wcmtext inside column to creates a column Of width W cmOf height Hcm

documentclassarticlebegindocumentparbox3cmTUG is an acronym It means TeX Users Groupenddocument

lhyphenationacro-nym---gt states division points for wordsluserdquousepackage[none]hyphenatrdquolusepackage[htt]hyphenat- enables hyphens

lInner alignmentlcmdashvertically center the text in the boxltmdashplace text at the top of the boxlbmdashplace text at its bottomlsmdashstretch the text vertically if possible

Paragraph Boxes

The text within a paragraph boxworks just like a paragraph exceptthat the author sets thewidthparbox2inThe text within sets the widthYou can accomplish the same thing with the minipageenvironment

Syntaxparboxwidthtext

beginminipagewidthtext

endminipage

Accents and Ellipses

AccentsIf you need accented characters like from a different languageyoursquoll need some special commands

Ellipsestype It was the best of times dotssee It was the best of times

using accents directly

Use package inputenc

Exampledocumentclassarticleusepackage[utf8]inputencbegindocumentNatildeo compreendo Haacute aqui algueacutem que fale inglecircsComment ccedilava Ougrave se trouve laeacuteroportenddocument

inputenc package The option utf8 tells the package to use Unicode inputencoding which provides many more symbols than just the ASCII code

Units of the Document(Breaking Lines)

There are three ways to get a new line of text1 Insert a blank line in the tex file This produces a newparagraph2 Use the command Text after the double backslash willappear on the next line without any indentation (Make sureyou have a space in the tex file after the to achieve this)3 Use newline This functions the same way as Most prefer because of this added functionality

Command Effect[length] creates interline space of length prevents page break after line[length] combination

nolinebreak[length] This command prevents a line break at the current position

An Example

TypeI think we should continuethis conversation [3in] down here

See

I think we should continue this conversation

down hereAcceptable units of measurement in cm pt

Breaking Paragraphs

lWersquove seen that a blank line in your file produces a new paragraphlwe might not want this paragraph indented (It is indented by default)lUse the command noindent before the first line of the next paragraph

documentclassarticlebegindocumentThis is indentednoindent This is notenddocument

Insert the following line into the preamble hyphenationacro-nym tells latex that word acronym has to be hyphenatedhyphenationacronym or mboxacronym will prevent hyphenation of acronymmboxtext will also prevent a line break for the complete text

Spacing in Paragraphs

to distinguish paragraphs there are two common wayslindent thebeginning of each paragraph(default latex syle)lto insert vertical space between paragraphs while omitting the indentation (suitable for narrow columns where indenting would cost too much width)

Load the parskip packagelremoves the paragraph indentation completelyl Introduces a skip between paragraphs

documentclassarticleusepackageparskipusepackageurlbegindocumentThe authors of the CTAN team listed ten good reasonsfor using TeX Among them areTeX has the best output ldotsThe original text can be found onurl httpwwwctanorgwhat_is_texhtmlenddocument

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 7: Latex Liyaqat

The Weaknesses of LATEX

lFairly steep learning curvelcomplex formatting may occasionally take more time thanla word processor (eg tables)lCollaborators unfamiliar with LaTeX will have difficulty reviewing yourlmanuscriptslMany features require libraries which you have to findbe made aware lof (view changes etc)lLayout changes are difficult (ie will require time for you to hunt down lsolution and implement it)

A Simple LaTeX Document

documentclassarticle

begindocument

Hello world enddocument

bullLaTeXbullPreamble

bullBody

Class File

Defines what your document will look like First line of all LaTeX documentsSelected by documentclass commanddocumentclass[options]class_nameSome examplesamsartcls (included with basic download)documentclass[]amsartIEEEtrancls (download from [4])Specify font size number of columns format etcdocumentclass[10ptconference]IEEEtran

larticlelreportlbooklletter

lBasic Classes

Class Files - Examples

Macro Packages

lPreamble area is use for document formatting purposelAll the packages needed to format the document are defined in this area of latex documentlAllow you to use special commandslPackages are activated byusepackage[options]package_nameExamples

bull citesty bull usepackagecite

bull graphicxsty bull usepackagegraphicx

bull geometrysty bull usepackage[margin=1in]geometry

bull urlsty bull usepackageurl

A Quick Review

bullLaTeX

writing special characters in our text

The following symbols are reserved $ amp _ ^ ~ To include them in your text $ amp _ ^ ~ Note you cannot just do (which is a linebreak) but instead$backslash$ or textbackslash

The Font Size Option

All of LATEXrsquos font size adjustments are set based upon the normalsize for the document1 The default text size for a document is 10 point2 To make a change use an optional argument on thedocumentclass commanddocumentclass[12pt]article

3 Permitted font sizes for the article class 9 10 11 12

Changing SizesFrom smallest to largest

CommandtinyscriptsizefootnotesizesmallnormalsizelargeLargeLARGEhugeHuge

bullOptional argument

Formatting text ndash fonts shapes and styles

Making words appear bold italic or slantedhow to highlight words in a part of some text thats already emphasized

Commandsemphused to put emphasis on a textGeneral Format of text formatting commands textargumentWhere is ldquobfrdquo for bold font ldquoitrdquo for ittallic ldquoslrdquo for Slanted ldquosfrdquo for San-serif font ldquottrdquo for Type-writer font

Two Examples

An example of changing font sizes within a documenttype These large words Large get LARGE big

see These words get bigAnother exampletype Lots huge of differentsmall sizes tiny of normalsize textsee Lotsof different sizes of text

Changing colors for soul

You can change the strikethrough highlighting and underlineusepackagesoulstHellow worldColorssetstcolorred Makes the strikethrough redsethlcolorgreen Makes the highlight color greensetulcolororange Makes the underline color orange

$X^2$ --Superscript$X_2$ -- Subscript

Text Justification

Environments are necessary to change the standard full justificationthat LATEX uses

Environment EffectCenter Centered textFlushright Right justificationFlushleft Left justification

ExampledocumentclassarticlebegindocumentbegincenterHello worldendcenterenddocument

Other waysraggedright justifies text to rightraggedleft justifies text to leftcenteringtext justifies text to center

creating a narrow text column amp word divisions

Sometimes wed like a paragraph to have a smaller width we would like to put text and a picture side-by-side

parbox[alignment][Hcm][inner alignment]Wcmtext inside column to creates a column Of width W cmOf height Hcm

documentclassarticlebegindocumentparbox3cmTUG is an acronym It means TeX Users Groupenddocument

lhyphenationacro-nym---gt states division points for wordsluserdquousepackage[none]hyphenatrdquolusepackage[htt]hyphenat- enables hyphens

lInner alignmentlcmdashvertically center the text in the boxltmdashplace text at the top of the boxlbmdashplace text at its bottomlsmdashstretch the text vertically if possible

Paragraph Boxes

The text within a paragraph boxworks just like a paragraph exceptthat the author sets thewidthparbox2inThe text within sets the widthYou can accomplish the same thing with the minipageenvironment

Syntaxparboxwidthtext

beginminipagewidthtext

endminipage

Accents and Ellipses

AccentsIf you need accented characters like from a different languageyoursquoll need some special commands

Ellipsestype It was the best of times dotssee It was the best of times

using accents directly

Use package inputenc

Exampledocumentclassarticleusepackage[utf8]inputencbegindocumentNatildeo compreendo Haacute aqui algueacutem que fale inglecircsComment ccedilava Ougrave se trouve laeacuteroportenddocument

inputenc package The option utf8 tells the package to use Unicode inputencoding which provides many more symbols than just the ASCII code

Units of the Document(Breaking Lines)

There are three ways to get a new line of text1 Insert a blank line in the tex file This produces a newparagraph2 Use the command Text after the double backslash willappear on the next line without any indentation (Make sureyou have a space in the tex file after the to achieve this)3 Use newline This functions the same way as Most prefer because of this added functionality

Command Effect[length] creates interline space of length prevents page break after line[length] combination

nolinebreak[length] This command prevents a line break at the current position

An Example

TypeI think we should continuethis conversation [3in] down here

See

I think we should continue this conversation

down hereAcceptable units of measurement in cm pt

Breaking Paragraphs

lWersquove seen that a blank line in your file produces a new paragraphlwe might not want this paragraph indented (It is indented by default)lUse the command noindent before the first line of the next paragraph

documentclassarticlebegindocumentThis is indentednoindent This is notenddocument

Insert the following line into the preamble hyphenationacro-nym tells latex that word acronym has to be hyphenatedhyphenationacronym or mboxacronym will prevent hyphenation of acronymmboxtext will also prevent a line break for the complete text

Spacing in Paragraphs

to distinguish paragraphs there are two common wayslindent thebeginning of each paragraph(default latex syle)lto insert vertical space between paragraphs while omitting the indentation (suitable for narrow columns where indenting would cost too much width)

Load the parskip packagelremoves the paragraph indentation completelyl Introduces a skip between paragraphs

documentclassarticleusepackageparskipusepackageurlbegindocumentThe authors of the CTAN team listed ten good reasonsfor using TeX Among them areTeX has the best output ldotsThe original text can be found onurl httpwwwctanorgwhat_is_texhtmlenddocument

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 8: Latex Liyaqat

A Simple LaTeX Document

documentclassarticle

begindocument

Hello world enddocument

bullLaTeXbullPreamble

bullBody

Class File

Defines what your document will look like First line of all LaTeX documentsSelected by documentclass commanddocumentclass[options]class_nameSome examplesamsartcls (included with basic download)documentclass[]amsartIEEEtrancls (download from [4])Specify font size number of columns format etcdocumentclass[10ptconference]IEEEtran

larticlelreportlbooklletter

lBasic Classes

Class Files - Examples

Macro Packages

lPreamble area is use for document formatting purposelAll the packages needed to format the document are defined in this area of latex documentlAllow you to use special commandslPackages are activated byusepackage[options]package_nameExamples

bull citesty bull usepackagecite

bull graphicxsty bull usepackagegraphicx

bull geometrysty bull usepackage[margin=1in]geometry

bull urlsty bull usepackageurl

A Quick Review

bullLaTeX

writing special characters in our text

The following symbols are reserved $ amp _ ^ ~ To include them in your text $ amp _ ^ ~ Note you cannot just do (which is a linebreak) but instead$backslash$ or textbackslash

The Font Size Option

All of LATEXrsquos font size adjustments are set based upon the normalsize for the document1 The default text size for a document is 10 point2 To make a change use an optional argument on thedocumentclass commanddocumentclass[12pt]article

3 Permitted font sizes for the article class 9 10 11 12

Changing SizesFrom smallest to largest

CommandtinyscriptsizefootnotesizesmallnormalsizelargeLargeLARGEhugeHuge

bullOptional argument

Formatting text ndash fonts shapes and styles

Making words appear bold italic or slantedhow to highlight words in a part of some text thats already emphasized

Commandsemphused to put emphasis on a textGeneral Format of text formatting commands textargumentWhere is ldquobfrdquo for bold font ldquoitrdquo for ittallic ldquoslrdquo for Slanted ldquosfrdquo for San-serif font ldquottrdquo for Type-writer font

Two Examples

An example of changing font sizes within a documenttype These large words Large get LARGE big

see These words get bigAnother exampletype Lots huge of differentsmall sizes tiny of normalsize textsee Lotsof different sizes of text

Changing colors for soul

You can change the strikethrough highlighting and underlineusepackagesoulstHellow worldColorssetstcolorred Makes the strikethrough redsethlcolorgreen Makes the highlight color greensetulcolororange Makes the underline color orange

$X^2$ --Superscript$X_2$ -- Subscript

Text Justification

Environments are necessary to change the standard full justificationthat LATEX uses

Environment EffectCenter Centered textFlushright Right justificationFlushleft Left justification

ExampledocumentclassarticlebegindocumentbegincenterHello worldendcenterenddocument

Other waysraggedright justifies text to rightraggedleft justifies text to leftcenteringtext justifies text to center

creating a narrow text column amp word divisions

Sometimes wed like a paragraph to have a smaller width we would like to put text and a picture side-by-side

parbox[alignment][Hcm][inner alignment]Wcmtext inside column to creates a column Of width W cmOf height Hcm

documentclassarticlebegindocumentparbox3cmTUG is an acronym It means TeX Users Groupenddocument

lhyphenationacro-nym---gt states division points for wordsluserdquousepackage[none]hyphenatrdquolusepackage[htt]hyphenat- enables hyphens

lInner alignmentlcmdashvertically center the text in the boxltmdashplace text at the top of the boxlbmdashplace text at its bottomlsmdashstretch the text vertically if possible

Paragraph Boxes

The text within a paragraph boxworks just like a paragraph exceptthat the author sets thewidthparbox2inThe text within sets the widthYou can accomplish the same thing with the minipageenvironment

Syntaxparboxwidthtext

beginminipagewidthtext

endminipage

Accents and Ellipses

AccentsIf you need accented characters like from a different languageyoursquoll need some special commands

Ellipsestype It was the best of times dotssee It was the best of times

using accents directly

Use package inputenc

Exampledocumentclassarticleusepackage[utf8]inputencbegindocumentNatildeo compreendo Haacute aqui algueacutem que fale inglecircsComment ccedilava Ougrave se trouve laeacuteroportenddocument

inputenc package The option utf8 tells the package to use Unicode inputencoding which provides many more symbols than just the ASCII code

Units of the Document(Breaking Lines)

There are three ways to get a new line of text1 Insert a blank line in the tex file This produces a newparagraph2 Use the command Text after the double backslash willappear on the next line without any indentation (Make sureyou have a space in the tex file after the to achieve this)3 Use newline This functions the same way as Most prefer because of this added functionality

Command Effect[length] creates interline space of length prevents page break after line[length] combination

nolinebreak[length] This command prevents a line break at the current position

An Example

TypeI think we should continuethis conversation [3in] down here

See

I think we should continue this conversation

down hereAcceptable units of measurement in cm pt

Breaking Paragraphs

lWersquove seen that a blank line in your file produces a new paragraphlwe might not want this paragraph indented (It is indented by default)lUse the command noindent before the first line of the next paragraph

documentclassarticlebegindocumentThis is indentednoindent This is notenddocument

Insert the following line into the preamble hyphenationacro-nym tells latex that word acronym has to be hyphenatedhyphenationacronym or mboxacronym will prevent hyphenation of acronymmboxtext will also prevent a line break for the complete text

Spacing in Paragraphs

to distinguish paragraphs there are two common wayslindent thebeginning of each paragraph(default latex syle)lto insert vertical space between paragraphs while omitting the indentation (suitable for narrow columns where indenting would cost too much width)

Load the parskip packagelremoves the paragraph indentation completelyl Introduces a skip between paragraphs

documentclassarticleusepackageparskipusepackageurlbegindocumentThe authors of the CTAN team listed ten good reasonsfor using TeX Among them areTeX has the best output ldotsThe original text can be found onurl httpwwwctanorgwhat_is_texhtmlenddocument

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 9: Latex Liyaqat

Class File

Defines what your document will look like First line of all LaTeX documentsSelected by documentclass commanddocumentclass[options]class_nameSome examplesamsartcls (included with basic download)documentclass[]amsartIEEEtrancls (download from [4])Specify font size number of columns format etcdocumentclass[10ptconference]IEEEtran

larticlelreportlbooklletter

lBasic Classes

Class Files - Examples

Macro Packages

lPreamble area is use for document formatting purposelAll the packages needed to format the document are defined in this area of latex documentlAllow you to use special commandslPackages are activated byusepackage[options]package_nameExamples

bull citesty bull usepackagecite

bull graphicxsty bull usepackagegraphicx

bull geometrysty bull usepackage[margin=1in]geometry

bull urlsty bull usepackageurl

A Quick Review

bullLaTeX

writing special characters in our text

The following symbols are reserved $ amp _ ^ ~ To include them in your text $ amp _ ^ ~ Note you cannot just do (which is a linebreak) but instead$backslash$ or textbackslash

The Font Size Option

All of LATEXrsquos font size adjustments are set based upon the normalsize for the document1 The default text size for a document is 10 point2 To make a change use an optional argument on thedocumentclass commanddocumentclass[12pt]article

3 Permitted font sizes for the article class 9 10 11 12

Changing SizesFrom smallest to largest

CommandtinyscriptsizefootnotesizesmallnormalsizelargeLargeLARGEhugeHuge

bullOptional argument

Formatting text ndash fonts shapes and styles

Making words appear bold italic or slantedhow to highlight words in a part of some text thats already emphasized

Commandsemphused to put emphasis on a textGeneral Format of text formatting commands textargumentWhere is ldquobfrdquo for bold font ldquoitrdquo for ittallic ldquoslrdquo for Slanted ldquosfrdquo for San-serif font ldquottrdquo for Type-writer font

Two Examples

An example of changing font sizes within a documenttype These large words Large get LARGE big

see These words get bigAnother exampletype Lots huge of differentsmall sizes tiny of normalsize textsee Lotsof different sizes of text

Changing colors for soul

You can change the strikethrough highlighting and underlineusepackagesoulstHellow worldColorssetstcolorred Makes the strikethrough redsethlcolorgreen Makes the highlight color greensetulcolororange Makes the underline color orange

$X^2$ --Superscript$X_2$ -- Subscript

Text Justification

Environments are necessary to change the standard full justificationthat LATEX uses

Environment EffectCenter Centered textFlushright Right justificationFlushleft Left justification

ExampledocumentclassarticlebegindocumentbegincenterHello worldendcenterenddocument

Other waysraggedright justifies text to rightraggedleft justifies text to leftcenteringtext justifies text to center

creating a narrow text column amp word divisions

Sometimes wed like a paragraph to have a smaller width we would like to put text and a picture side-by-side

parbox[alignment][Hcm][inner alignment]Wcmtext inside column to creates a column Of width W cmOf height Hcm

documentclassarticlebegindocumentparbox3cmTUG is an acronym It means TeX Users Groupenddocument

lhyphenationacro-nym---gt states division points for wordsluserdquousepackage[none]hyphenatrdquolusepackage[htt]hyphenat- enables hyphens

lInner alignmentlcmdashvertically center the text in the boxltmdashplace text at the top of the boxlbmdashplace text at its bottomlsmdashstretch the text vertically if possible

Paragraph Boxes

The text within a paragraph boxworks just like a paragraph exceptthat the author sets thewidthparbox2inThe text within sets the widthYou can accomplish the same thing with the minipageenvironment

Syntaxparboxwidthtext

beginminipagewidthtext

endminipage

Accents and Ellipses

AccentsIf you need accented characters like from a different languageyoursquoll need some special commands

Ellipsestype It was the best of times dotssee It was the best of times

using accents directly

Use package inputenc

Exampledocumentclassarticleusepackage[utf8]inputencbegindocumentNatildeo compreendo Haacute aqui algueacutem que fale inglecircsComment ccedilava Ougrave se trouve laeacuteroportenddocument

inputenc package The option utf8 tells the package to use Unicode inputencoding which provides many more symbols than just the ASCII code

Units of the Document(Breaking Lines)

There are three ways to get a new line of text1 Insert a blank line in the tex file This produces a newparagraph2 Use the command Text after the double backslash willappear on the next line without any indentation (Make sureyou have a space in the tex file after the to achieve this)3 Use newline This functions the same way as Most prefer because of this added functionality

Command Effect[length] creates interline space of length prevents page break after line[length] combination

nolinebreak[length] This command prevents a line break at the current position

An Example

TypeI think we should continuethis conversation [3in] down here

See

I think we should continue this conversation

down hereAcceptable units of measurement in cm pt

Breaking Paragraphs

lWersquove seen that a blank line in your file produces a new paragraphlwe might not want this paragraph indented (It is indented by default)lUse the command noindent before the first line of the next paragraph

documentclassarticlebegindocumentThis is indentednoindent This is notenddocument

Insert the following line into the preamble hyphenationacro-nym tells latex that word acronym has to be hyphenatedhyphenationacronym or mboxacronym will prevent hyphenation of acronymmboxtext will also prevent a line break for the complete text

Spacing in Paragraphs

to distinguish paragraphs there are two common wayslindent thebeginning of each paragraph(default latex syle)lto insert vertical space between paragraphs while omitting the indentation (suitable for narrow columns where indenting would cost too much width)

Load the parskip packagelremoves the paragraph indentation completelyl Introduces a skip between paragraphs

documentclassarticleusepackageparskipusepackageurlbegindocumentThe authors of the CTAN team listed ten good reasonsfor using TeX Among them areTeX has the best output ldotsThe original text can be found onurl httpwwwctanorgwhat_is_texhtmlenddocument

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 10: Latex Liyaqat

Class Files - Examples

Macro Packages

lPreamble area is use for document formatting purposelAll the packages needed to format the document are defined in this area of latex documentlAllow you to use special commandslPackages are activated byusepackage[options]package_nameExamples

bull citesty bull usepackagecite

bull graphicxsty bull usepackagegraphicx

bull geometrysty bull usepackage[margin=1in]geometry

bull urlsty bull usepackageurl

A Quick Review

bullLaTeX

writing special characters in our text

The following symbols are reserved $ amp _ ^ ~ To include them in your text $ amp _ ^ ~ Note you cannot just do (which is a linebreak) but instead$backslash$ or textbackslash

The Font Size Option

All of LATEXrsquos font size adjustments are set based upon the normalsize for the document1 The default text size for a document is 10 point2 To make a change use an optional argument on thedocumentclass commanddocumentclass[12pt]article

3 Permitted font sizes for the article class 9 10 11 12

Changing SizesFrom smallest to largest

CommandtinyscriptsizefootnotesizesmallnormalsizelargeLargeLARGEhugeHuge

bullOptional argument

Formatting text ndash fonts shapes and styles

Making words appear bold italic or slantedhow to highlight words in a part of some text thats already emphasized

Commandsemphused to put emphasis on a textGeneral Format of text formatting commands textargumentWhere is ldquobfrdquo for bold font ldquoitrdquo for ittallic ldquoslrdquo for Slanted ldquosfrdquo for San-serif font ldquottrdquo for Type-writer font

Two Examples

An example of changing font sizes within a documenttype These large words Large get LARGE big

see These words get bigAnother exampletype Lots huge of differentsmall sizes tiny of normalsize textsee Lotsof different sizes of text

Changing colors for soul

You can change the strikethrough highlighting and underlineusepackagesoulstHellow worldColorssetstcolorred Makes the strikethrough redsethlcolorgreen Makes the highlight color greensetulcolororange Makes the underline color orange

$X^2$ --Superscript$X_2$ -- Subscript

Text Justification

Environments are necessary to change the standard full justificationthat LATEX uses

Environment EffectCenter Centered textFlushright Right justificationFlushleft Left justification

ExampledocumentclassarticlebegindocumentbegincenterHello worldendcenterenddocument

Other waysraggedright justifies text to rightraggedleft justifies text to leftcenteringtext justifies text to center

creating a narrow text column amp word divisions

Sometimes wed like a paragraph to have a smaller width we would like to put text and a picture side-by-side

parbox[alignment][Hcm][inner alignment]Wcmtext inside column to creates a column Of width W cmOf height Hcm

documentclassarticlebegindocumentparbox3cmTUG is an acronym It means TeX Users Groupenddocument

lhyphenationacro-nym---gt states division points for wordsluserdquousepackage[none]hyphenatrdquolusepackage[htt]hyphenat- enables hyphens

lInner alignmentlcmdashvertically center the text in the boxltmdashplace text at the top of the boxlbmdashplace text at its bottomlsmdashstretch the text vertically if possible

Paragraph Boxes

The text within a paragraph boxworks just like a paragraph exceptthat the author sets thewidthparbox2inThe text within sets the widthYou can accomplish the same thing with the minipageenvironment

Syntaxparboxwidthtext

beginminipagewidthtext

endminipage

Accents and Ellipses

AccentsIf you need accented characters like from a different languageyoursquoll need some special commands

Ellipsestype It was the best of times dotssee It was the best of times

using accents directly

Use package inputenc

Exampledocumentclassarticleusepackage[utf8]inputencbegindocumentNatildeo compreendo Haacute aqui algueacutem que fale inglecircsComment ccedilava Ougrave se trouve laeacuteroportenddocument

inputenc package The option utf8 tells the package to use Unicode inputencoding which provides many more symbols than just the ASCII code

Units of the Document(Breaking Lines)

There are three ways to get a new line of text1 Insert a blank line in the tex file This produces a newparagraph2 Use the command Text after the double backslash willappear on the next line without any indentation (Make sureyou have a space in the tex file after the to achieve this)3 Use newline This functions the same way as Most prefer because of this added functionality

Command Effect[length] creates interline space of length prevents page break after line[length] combination

nolinebreak[length] This command prevents a line break at the current position

An Example

TypeI think we should continuethis conversation [3in] down here

See

I think we should continue this conversation

down hereAcceptable units of measurement in cm pt

Breaking Paragraphs

lWersquove seen that a blank line in your file produces a new paragraphlwe might not want this paragraph indented (It is indented by default)lUse the command noindent before the first line of the next paragraph

documentclassarticlebegindocumentThis is indentednoindent This is notenddocument

Insert the following line into the preamble hyphenationacro-nym tells latex that word acronym has to be hyphenatedhyphenationacronym or mboxacronym will prevent hyphenation of acronymmboxtext will also prevent a line break for the complete text

Spacing in Paragraphs

to distinguish paragraphs there are two common wayslindent thebeginning of each paragraph(default latex syle)lto insert vertical space between paragraphs while omitting the indentation (suitable for narrow columns where indenting would cost too much width)

Load the parskip packagelremoves the paragraph indentation completelyl Introduces a skip between paragraphs

documentclassarticleusepackageparskipusepackageurlbegindocumentThe authors of the CTAN team listed ten good reasonsfor using TeX Among them areTeX has the best output ldotsThe original text can be found onurl httpwwwctanorgwhat_is_texhtmlenddocument

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 11: Latex Liyaqat

Macro Packages

lPreamble area is use for document formatting purposelAll the packages needed to format the document are defined in this area of latex documentlAllow you to use special commandslPackages are activated byusepackage[options]package_nameExamples

bull citesty bull usepackagecite

bull graphicxsty bull usepackagegraphicx

bull geometrysty bull usepackage[margin=1in]geometry

bull urlsty bull usepackageurl

A Quick Review

bullLaTeX

writing special characters in our text

The following symbols are reserved $ amp _ ^ ~ To include them in your text $ amp _ ^ ~ Note you cannot just do (which is a linebreak) but instead$backslash$ or textbackslash

The Font Size Option

All of LATEXrsquos font size adjustments are set based upon the normalsize for the document1 The default text size for a document is 10 point2 To make a change use an optional argument on thedocumentclass commanddocumentclass[12pt]article

3 Permitted font sizes for the article class 9 10 11 12

Changing SizesFrom smallest to largest

CommandtinyscriptsizefootnotesizesmallnormalsizelargeLargeLARGEhugeHuge

bullOptional argument

Formatting text ndash fonts shapes and styles

Making words appear bold italic or slantedhow to highlight words in a part of some text thats already emphasized

Commandsemphused to put emphasis on a textGeneral Format of text formatting commands textargumentWhere is ldquobfrdquo for bold font ldquoitrdquo for ittallic ldquoslrdquo for Slanted ldquosfrdquo for San-serif font ldquottrdquo for Type-writer font

Two Examples

An example of changing font sizes within a documenttype These large words Large get LARGE big

see These words get bigAnother exampletype Lots huge of differentsmall sizes tiny of normalsize textsee Lotsof different sizes of text

Changing colors for soul

You can change the strikethrough highlighting and underlineusepackagesoulstHellow worldColorssetstcolorred Makes the strikethrough redsethlcolorgreen Makes the highlight color greensetulcolororange Makes the underline color orange

$X^2$ --Superscript$X_2$ -- Subscript

Text Justification

Environments are necessary to change the standard full justificationthat LATEX uses

Environment EffectCenter Centered textFlushright Right justificationFlushleft Left justification

ExampledocumentclassarticlebegindocumentbegincenterHello worldendcenterenddocument

Other waysraggedright justifies text to rightraggedleft justifies text to leftcenteringtext justifies text to center

creating a narrow text column amp word divisions

Sometimes wed like a paragraph to have a smaller width we would like to put text and a picture side-by-side

parbox[alignment][Hcm][inner alignment]Wcmtext inside column to creates a column Of width W cmOf height Hcm

documentclassarticlebegindocumentparbox3cmTUG is an acronym It means TeX Users Groupenddocument

lhyphenationacro-nym---gt states division points for wordsluserdquousepackage[none]hyphenatrdquolusepackage[htt]hyphenat- enables hyphens

lInner alignmentlcmdashvertically center the text in the boxltmdashplace text at the top of the boxlbmdashplace text at its bottomlsmdashstretch the text vertically if possible

Paragraph Boxes

The text within a paragraph boxworks just like a paragraph exceptthat the author sets thewidthparbox2inThe text within sets the widthYou can accomplish the same thing with the minipageenvironment

Syntaxparboxwidthtext

beginminipagewidthtext

endminipage

Accents and Ellipses

AccentsIf you need accented characters like from a different languageyoursquoll need some special commands

Ellipsestype It was the best of times dotssee It was the best of times

using accents directly

Use package inputenc

Exampledocumentclassarticleusepackage[utf8]inputencbegindocumentNatildeo compreendo Haacute aqui algueacutem que fale inglecircsComment ccedilava Ougrave se trouve laeacuteroportenddocument

inputenc package The option utf8 tells the package to use Unicode inputencoding which provides many more symbols than just the ASCII code

Units of the Document(Breaking Lines)

There are three ways to get a new line of text1 Insert a blank line in the tex file This produces a newparagraph2 Use the command Text after the double backslash willappear on the next line without any indentation (Make sureyou have a space in the tex file after the to achieve this)3 Use newline This functions the same way as Most prefer because of this added functionality

Command Effect[length] creates interline space of length prevents page break after line[length] combination

nolinebreak[length] This command prevents a line break at the current position

An Example

TypeI think we should continuethis conversation [3in] down here

See

I think we should continue this conversation

down hereAcceptable units of measurement in cm pt

Breaking Paragraphs

lWersquove seen that a blank line in your file produces a new paragraphlwe might not want this paragraph indented (It is indented by default)lUse the command noindent before the first line of the next paragraph

documentclassarticlebegindocumentThis is indentednoindent This is notenddocument

Insert the following line into the preamble hyphenationacro-nym tells latex that word acronym has to be hyphenatedhyphenationacronym or mboxacronym will prevent hyphenation of acronymmboxtext will also prevent a line break for the complete text

Spacing in Paragraphs

to distinguish paragraphs there are two common wayslindent thebeginning of each paragraph(default latex syle)lto insert vertical space between paragraphs while omitting the indentation (suitable for narrow columns where indenting would cost too much width)

Load the parskip packagelremoves the paragraph indentation completelyl Introduces a skip between paragraphs

documentclassarticleusepackageparskipusepackageurlbegindocumentThe authors of the CTAN team listed ten good reasonsfor using TeX Among them areTeX has the best output ldotsThe original text can be found onurl httpwwwctanorgwhat_is_texhtmlenddocument

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 12: Latex Liyaqat

A Quick Review

bullLaTeX

writing special characters in our text

The following symbols are reserved $ amp _ ^ ~ To include them in your text $ amp _ ^ ~ Note you cannot just do (which is a linebreak) but instead$backslash$ or textbackslash

The Font Size Option

All of LATEXrsquos font size adjustments are set based upon the normalsize for the document1 The default text size for a document is 10 point2 To make a change use an optional argument on thedocumentclass commanddocumentclass[12pt]article

3 Permitted font sizes for the article class 9 10 11 12

Changing SizesFrom smallest to largest

CommandtinyscriptsizefootnotesizesmallnormalsizelargeLargeLARGEhugeHuge

bullOptional argument

Formatting text ndash fonts shapes and styles

Making words appear bold italic or slantedhow to highlight words in a part of some text thats already emphasized

Commandsemphused to put emphasis on a textGeneral Format of text formatting commands textargumentWhere is ldquobfrdquo for bold font ldquoitrdquo for ittallic ldquoslrdquo for Slanted ldquosfrdquo for San-serif font ldquottrdquo for Type-writer font

Two Examples

An example of changing font sizes within a documenttype These large words Large get LARGE big

see These words get bigAnother exampletype Lots huge of differentsmall sizes tiny of normalsize textsee Lotsof different sizes of text

Changing colors for soul

You can change the strikethrough highlighting and underlineusepackagesoulstHellow worldColorssetstcolorred Makes the strikethrough redsethlcolorgreen Makes the highlight color greensetulcolororange Makes the underline color orange

$X^2$ --Superscript$X_2$ -- Subscript

Text Justification

Environments are necessary to change the standard full justificationthat LATEX uses

Environment EffectCenter Centered textFlushright Right justificationFlushleft Left justification

ExampledocumentclassarticlebegindocumentbegincenterHello worldendcenterenddocument

Other waysraggedright justifies text to rightraggedleft justifies text to leftcenteringtext justifies text to center

creating a narrow text column amp word divisions

Sometimes wed like a paragraph to have a smaller width we would like to put text and a picture side-by-side

parbox[alignment][Hcm][inner alignment]Wcmtext inside column to creates a column Of width W cmOf height Hcm

documentclassarticlebegindocumentparbox3cmTUG is an acronym It means TeX Users Groupenddocument

lhyphenationacro-nym---gt states division points for wordsluserdquousepackage[none]hyphenatrdquolusepackage[htt]hyphenat- enables hyphens

lInner alignmentlcmdashvertically center the text in the boxltmdashplace text at the top of the boxlbmdashplace text at its bottomlsmdashstretch the text vertically if possible

Paragraph Boxes

The text within a paragraph boxworks just like a paragraph exceptthat the author sets thewidthparbox2inThe text within sets the widthYou can accomplish the same thing with the minipageenvironment

Syntaxparboxwidthtext

beginminipagewidthtext

endminipage

Accents and Ellipses

AccentsIf you need accented characters like from a different languageyoursquoll need some special commands

Ellipsestype It was the best of times dotssee It was the best of times

using accents directly

Use package inputenc

Exampledocumentclassarticleusepackage[utf8]inputencbegindocumentNatildeo compreendo Haacute aqui algueacutem que fale inglecircsComment ccedilava Ougrave se trouve laeacuteroportenddocument

inputenc package The option utf8 tells the package to use Unicode inputencoding which provides many more symbols than just the ASCII code

Units of the Document(Breaking Lines)

There are three ways to get a new line of text1 Insert a blank line in the tex file This produces a newparagraph2 Use the command Text after the double backslash willappear on the next line without any indentation (Make sureyou have a space in the tex file after the to achieve this)3 Use newline This functions the same way as Most prefer because of this added functionality

Command Effect[length] creates interline space of length prevents page break after line[length] combination

nolinebreak[length] This command prevents a line break at the current position

An Example

TypeI think we should continuethis conversation [3in] down here

See

I think we should continue this conversation

down hereAcceptable units of measurement in cm pt

Breaking Paragraphs

lWersquove seen that a blank line in your file produces a new paragraphlwe might not want this paragraph indented (It is indented by default)lUse the command noindent before the first line of the next paragraph

documentclassarticlebegindocumentThis is indentednoindent This is notenddocument

Insert the following line into the preamble hyphenationacro-nym tells latex that word acronym has to be hyphenatedhyphenationacronym or mboxacronym will prevent hyphenation of acronymmboxtext will also prevent a line break for the complete text

Spacing in Paragraphs

to distinguish paragraphs there are two common wayslindent thebeginning of each paragraph(default latex syle)lto insert vertical space between paragraphs while omitting the indentation (suitable for narrow columns where indenting would cost too much width)

Load the parskip packagelremoves the paragraph indentation completelyl Introduces a skip between paragraphs

documentclassarticleusepackageparskipusepackageurlbegindocumentThe authors of the CTAN team listed ten good reasonsfor using TeX Among them areTeX has the best output ldotsThe original text can be found onurl httpwwwctanorgwhat_is_texhtmlenddocument

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 13: Latex Liyaqat

writing special characters in our text

The following symbols are reserved $ amp _ ^ ~ To include them in your text $ amp _ ^ ~ Note you cannot just do (which is a linebreak) but instead$backslash$ or textbackslash

The Font Size Option

All of LATEXrsquos font size adjustments are set based upon the normalsize for the document1 The default text size for a document is 10 point2 To make a change use an optional argument on thedocumentclass commanddocumentclass[12pt]article

3 Permitted font sizes for the article class 9 10 11 12

Changing SizesFrom smallest to largest

CommandtinyscriptsizefootnotesizesmallnormalsizelargeLargeLARGEhugeHuge

bullOptional argument

Formatting text ndash fonts shapes and styles

Making words appear bold italic or slantedhow to highlight words in a part of some text thats already emphasized

Commandsemphused to put emphasis on a textGeneral Format of text formatting commands textargumentWhere is ldquobfrdquo for bold font ldquoitrdquo for ittallic ldquoslrdquo for Slanted ldquosfrdquo for San-serif font ldquottrdquo for Type-writer font

Two Examples

An example of changing font sizes within a documenttype These large words Large get LARGE big

see These words get bigAnother exampletype Lots huge of differentsmall sizes tiny of normalsize textsee Lotsof different sizes of text

Changing colors for soul

You can change the strikethrough highlighting and underlineusepackagesoulstHellow worldColorssetstcolorred Makes the strikethrough redsethlcolorgreen Makes the highlight color greensetulcolororange Makes the underline color orange

$X^2$ --Superscript$X_2$ -- Subscript

Text Justification

Environments are necessary to change the standard full justificationthat LATEX uses

Environment EffectCenter Centered textFlushright Right justificationFlushleft Left justification

ExampledocumentclassarticlebegindocumentbegincenterHello worldendcenterenddocument

Other waysraggedright justifies text to rightraggedleft justifies text to leftcenteringtext justifies text to center

creating a narrow text column amp word divisions

Sometimes wed like a paragraph to have a smaller width we would like to put text and a picture side-by-side

parbox[alignment][Hcm][inner alignment]Wcmtext inside column to creates a column Of width W cmOf height Hcm

documentclassarticlebegindocumentparbox3cmTUG is an acronym It means TeX Users Groupenddocument

lhyphenationacro-nym---gt states division points for wordsluserdquousepackage[none]hyphenatrdquolusepackage[htt]hyphenat- enables hyphens

lInner alignmentlcmdashvertically center the text in the boxltmdashplace text at the top of the boxlbmdashplace text at its bottomlsmdashstretch the text vertically if possible

Paragraph Boxes

The text within a paragraph boxworks just like a paragraph exceptthat the author sets thewidthparbox2inThe text within sets the widthYou can accomplish the same thing with the minipageenvironment

Syntaxparboxwidthtext

beginminipagewidthtext

endminipage

Accents and Ellipses

AccentsIf you need accented characters like from a different languageyoursquoll need some special commands

Ellipsestype It was the best of times dotssee It was the best of times

using accents directly

Use package inputenc

Exampledocumentclassarticleusepackage[utf8]inputencbegindocumentNatildeo compreendo Haacute aqui algueacutem que fale inglecircsComment ccedilava Ougrave se trouve laeacuteroportenddocument

inputenc package The option utf8 tells the package to use Unicode inputencoding which provides many more symbols than just the ASCII code

Units of the Document(Breaking Lines)

There are three ways to get a new line of text1 Insert a blank line in the tex file This produces a newparagraph2 Use the command Text after the double backslash willappear on the next line without any indentation (Make sureyou have a space in the tex file after the to achieve this)3 Use newline This functions the same way as Most prefer because of this added functionality

Command Effect[length] creates interline space of length prevents page break after line[length] combination

nolinebreak[length] This command prevents a line break at the current position

An Example

TypeI think we should continuethis conversation [3in] down here

See

I think we should continue this conversation

down hereAcceptable units of measurement in cm pt

Breaking Paragraphs

lWersquove seen that a blank line in your file produces a new paragraphlwe might not want this paragraph indented (It is indented by default)lUse the command noindent before the first line of the next paragraph

documentclassarticlebegindocumentThis is indentednoindent This is notenddocument

Insert the following line into the preamble hyphenationacro-nym tells latex that word acronym has to be hyphenatedhyphenationacronym or mboxacronym will prevent hyphenation of acronymmboxtext will also prevent a line break for the complete text

Spacing in Paragraphs

to distinguish paragraphs there are two common wayslindent thebeginning of each paragraph(default latex syle)lto insert vertical space between paragraphs while omitting the indentation (suitable for narrow columns where indenting would cost too much width)

Load the parskip packagelremoves the paragraph indentation completelyl Introduces a skip between paragraphs

documentclassarticleusepackageparskipusepackageurlbegindocumentThe authors of the CTAN team listed ten good reasonsfor using TeX Among them areTeX has the best output ldotsThe original text can be found onurl httpwwwctanorgwhat_is_texhtmlenddocument

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 14: Latex Liyaqat

The Font Size Option

All of LATEXrsquos font size adjustments are set based upon the normalsize for the document1 The default text size for a document is 10 point2 To make a change use an optional argument on thedocumentclass commanddocumentclass[12pt]article

3 Permitted font sizes for the article class 9 10 11 12

Changing SizesFrom smallest to largest

CommandtinyscriptsizefootnotesizesmallnormalsizelargeLargeLARGEhugeHuge

bullOptional argument

Formatting text ndash fonts shapes and styles

Making words appear bold italic or slantedhow to highlight words in a part of some text thats already emphasized

Commandsemphused to put emphasis on a textGeneral Format of text formatting commands textargumentWhere is ldquobfrdquo for bold font ldquoitrdquo for ittallic ldquoslrdquo for Slanted ldquosfrdquo for San-serif font ldquottrdquo for Type-writer font

Two Examples

An example of changing font sizes within a documenttype These large words Large get LARGE big

see These words get bigAnother exampletype Lots huge of differentsmall sizes tiny of normalsize textsee Lotsof different sizes of text

Changing colors for soul

You can change the strikethrough highlighting and underlineusepackagesoulstHellow worldColorssetstcolorred Makes the strikethrough redsethlcolorgreen Makes the highlight color greensetulcolororange Makes the underline color orange

$X^2$ --Superscript$X_2$ -- Subscript

Text Justification

Environments are necessary to change the standard full justificationthat LATEX uses

Environment EffectCenter Centered textFlushright Right justificationFlushleft Left justification

ExampledocumentclassarticlebegindocumentbegincenterHello worldendcenterenddocument

Other waysraggedright justifies text to rightraggedleft justifies text to leftcenteringtext justifies text to center

creating a narrow text column amp word divisions

Sometimes wed like a paragraph to have a smaller width we would like to put text and a picture side-by-side

parbox[alignment][Hcm][inner alignment]Wcmtext inside column to creates a column Of width W cmOf height Hcm

documentclassarticlebegindocumentparbox3cmTUG is an acronym It means TeX Users Groupenddocument

lhyphenationacro-nym---gt states division points for wordsluserdquousepackage[none]hyphenatrdquolusepackage[htt]hyphenat- enables hyphens

lInner alignmentlcmdashvertically center the text in the boxltmdashplace text at the top of the boxlbmdashplace text at its bottomlsmdashstretch the text vertically if possible

Paragraph Boxes

The text within a paragraph boxworks just like a paragraph exceptthat the author sets thewidthparbox2inThe text within sets the widthYou can accomplish the same thing with the minipageenvironment

Syntaxparboxwidthtext

beginminipagewidthtext

endminipage

Accents and Ellipses

AccentsIf you need accented characters like from a different languageyoursquoll need some special commands

Ellipsestype It was the best of times dotssee It was the best of times

using accents directly

Use package inputenc

Exampledocumentclassarticleusepackage[utf8]inputencbegindocumentNatildeo compreendo Haacute aqui algueacutem que fale inglecircsComment ccedilava Ougrave se trouve laeacuteroportenddocument

inputenc package The option utf8 tells the package to use Unicode inputencoding which provides many more symbols than just the ASCII code

Units of the Document(Breaking Lines)

There are three ways to get a new line of text1 Insert a blank line in the tex file This produces a newparagraph2 Use the command Text after the double backslash willappear on the next line without any indentation (Make sureyou have a space in the tex file after the to achieve this)3 Use newline This functions the same way as Most prefer because of this added functionality

Command Effect[length] creates interline space of length prevents page break after line[length] combination

nolinebreak[length] This command prevents a line break at the current position

An Example

TypeI think we should continuethis conversation [3in] down here

See

I think we should continue this conversation

down hereAcceptable units of measurement in cm pt

Breaking Paragraphs

lWersquove seen that a blank line in your file produces a new paragraphlwe might not want this paragraph indented (It is indented by default)lUse the command noindent before the first line of the next paragraph

documentclassarticlebegindocumentThis is indentednoindent This is notenddocument

Insert the following line into the preamble hyphenationacro-nym tells latex that word acronym has to be hyphenatedhyphenationacronym or mboxacronym will prevent hyphenation of acronymmboxtext will also prevent a line break for the complete text

Spacing in Paragraphs

to distinguish paragraphs there are two common wayslindent thebeginning of each paragraph(default latex syle)lto insert vertical space between paragraphs while omitting the indentation (suitable for narrow columns where indenting would cost too much width)

Load the parskip packagelremoves the paragraph indentation completelyl Introduces a skip between paragraphs

documentclassarticleusepackageparskipusepackageurlbegindocumentThe authors of the CTAN team listed ten good reasonsfor using TeX Among them areTeX has the best output ldotsThe original text can be found onurl httpwwwctanorgwhat_is_texhtmlenddocument

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 15: Latex Liyaqat

Formatting text ndash fonts shapes and styles

Making words appear bold italic or slantedhow to highlight words in a part of some text thats already emphasized

Commandsemphused to put emphasis on a textGeneral Format of text formatting commands textargumentWhere is ldquobfrdquo for bold font ldquoitrdquo for ittallic ldquoslrdquo for Slanted ldquosfrdquo for San-serif font ldquottrdquo for Type-writer font

Two Examples

An example of changing font sizes within a documenttype These large words Large get LARGE big

see These words get bigAnother exampletype Lots huge of differentsmall sizes tiny of normalsize textsee Lotsof different sizes of text

Changing colors for soul

You can change the strikethrough highlighting and underlineusepackagesoulstHellow worldColorssetstcolorred Makes the strikethrough redsethlcolorgreen Makes the highlight color greensetulcolororange Makes the underline color orange

$X^2$ --Superscript$X_2$ -- Subscript

Text Justification

Environments are necessary to change the standard full justificationthat LATEX uses

Environment EffectCenter Centered textFlushright Right justificationFlushleft Left justification

ExampledocumentclassarticlebegindocumentbegincenterHello worldendcenterenddocument

Other waysraggedright justifies text to rightraggedleft justifies text to leftcenteringtext justifies text to center

creating a narrow text column amp word divisions

Sometimes wed like a paragraph to have a smaller width we would like to put text and a picture side-by-side

parbox[alignment][Hcm][inner alignment]Wcmtext inside column to creates a column Of width W cmOf height Hcm

documentclassarticlebegindocumentparbox3cmTUG is an acronym It means TeX Users Groupenddocument

lhyphenationacro-nym---gt states division points for wordsluserdquousepackage[none]hyphenatrdquolusepackage[htt]hyphenat- enables hyphens

lInner alignmentlcmdashvertically center the text in the boxltmdashplace text at the top of the boxlbmdashplace text at its bottomlsmdashstretch the text vertically if possible

Paragraph Boxes

The text within a paragraph boxworks just like a paragraph exceptthat the author sets thewidthparbox2inThe text within sets the widthYou can accomplish the same thing with the minipageenvironment

Syntaxparboxwidthtext

beginminipagewidthtext

endminipage

Accents and Ellipses

AccentsIf you need accented characters like from a different languageyoursquoll need some special commands

Ellipsestype It was the best of times dotssee It was the best of times

using accents directly

Use package inputenc

Exampledocumentclassarticleusepackage[utf8]inputencbegindocumentNatildeo compreendo Haacute aqui algueacutem que fale inglecircsComment ccedilava Ougrave se trouve laeacuteroportenddocument

inputenc package The option utf8 tells the package to use Unicode inputencoding which provides many more symbols than just the ASCII code

Units of the Document(Breaking Lines)

There are three ways to get a new line of text1 Insert a blank line in the tex file This produces a newparagraph2 Use the command Text after the double backslash willappear on the next line without any indentation (Make sureyou have a space in the tex file after the to achieve this)3 Use newline This functions the same way as Most prefer because of this added functionality

Command Effect[length] creates interline space of length prevents page break after line[length] combination

nolinebreak[length] This command prevents a line break at the current position

An Example

TypeI think we should continuethis conversation [3in] down here

See

I think we should continue this conversation

down hereAcceptable units of measurement in cm pt

Breaking Paragraphs

lWersquove seen that a blank line in your file produces a new paragraphlwe might not want this paragraph indented (It is indented by default)lUse the command noindent before the first line of the next paragraph

documentclassarticlebegindocumentThis is indentednoindent This is notenddocument

Insert the following line into the preamble hyphenationacro-nym tells latex that word acronym has to be hyphenatedhyphenationacronym or mboxacronym will prevent hyphenation of acronymmboxtext will also prevent a line break for the complete text

Spacing in Paragraphs

to distinguish paragraphs there are two common wayslindent thebeginning of each paragraph(default latex syle)lto insert vertical space between paragraphs while omitting the indentation (suitable for narrow columns where indenting would cost too much width)

Load the parskip packagelremoves the paragraph indentation completelyl Introduces a skip between paragraphs

documentclassarticleusepackageparskipusepackageurlbegindocumentThe authors of the CTAN team listed ten good reasonsfor using TeX Among them areTeX has the best output ldotsThe original text can be found onurl httpwwwctanorgwhat_is_texhtmlenddocument

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 16: Latex Liyaqat

Two Examples

An example of changing font sizes within a documenttype These large words Large get LARGE big

see These words get bigAnother exampletype Lots huge of differentsmall sizes tiny of normalsize textsee Lotsof different sizes of text

Changing colors for soul

You can change the strikethrough highlighting and underlineusepackagesoulstHellow worldColorssetstcolorred Makes the strikethrough redsethlcolorgreen Makes the highlight color greensetulcolororange Makes the underline color orange

$X^2$ --Superscript$X_2$ -- Subscript

Text Justification

Environments are necessary to change the standard full justificationthat LATEX uses

Environment EffectCenter Centered textFlushright Right justificationFlushleft Left justification

ExampledocumentclassarticlebegindocumentbegincenterHello worldendcenterenddocument

Other waysraggedright justifies text to rightraggedleft justifies text to leftcenteringtext justifies text to center

creating a narrow text column amp word divisions

Sometimes wed like a paragraph to have a smaller width we would like to put text and a picture side-by-side

parbox[alignment][Hcm][inner alignment]Wcmtext inside column to creates a column Of width W cmOf height Hcm

documentclassarticlebegindocumentparbox3cmTUG is an acronym It means TeX Users Groupenddocument

lhyphenationacro-nym---gt states division points for wordsluserdquousepackage[none]hyphenatrdquolusepackage[htt]hyphenat- enables hyphens

lInner alignmentlcmdashvertically center the text in the boxltmdashplace text at the top of the boxlbmdashplace text at its bottomlsmdashstretch the text vertically if possible

Paragraph Boxes

The text within a paragraph boxworks just like a paragraph exceptthat the author sets thewidthparbox2inThe text within sets the widthYou can accomplish the same thing with the minipageenvironment

Syntaxparboxwidthtext

beginminipagewidthtext

endminipage

Accents and Ellipses

AccentsIf you need accented characters like from a different languageyoursquoll need some special commands

Ellipsestype It was the best of times dotssee It was the best of times

using accents directly

Use package inputenc

Exampledocumentclassarticleusepackage[utf8]inputencbegindocumentNatildeo compreendo Haacute aqui algueacutem que fale inglecircsComment ccedilava Ougrave se trouve laeacuteroportenddocument

inputenc package The option utf8 tells the package to use Unicode inputencoding which provides many more symbols than just the ASCII code

Units of the Document(Breaking Lines)

There are three ways to get a new line of text1 Insert a blank line in the tex file This produces a newparagraph2 Use the command Text after the double backslash willappear on the next line without any indentation (Make sureyou have a space in the tex file after the to achieve this)3 Use newline This functions the same way as Most prefer because of this added functionality

Command Effect[length] creates interline space of length prevents page break after line[length] combination

nolinebreak[length] This command prevents a line break at the current position

An Example

TypeI think we should continuethis conversation [3in] down here

See

I think we should continue this conversation

down hereAcceptable units of measurement in cm pt

Breaking Paragraphs

lWersquove seen that a blank line in your file produces a new paragraphlwe might not want this paragraph indented (It is indented by default)lUse the command noindent before the first line of the next paragraph

documentclassarticlebegindocumentThis is indentednoindent This is notenddocument

Insert the following line into the preamble hyphenationacro-nym tells latex that word acronym has to be hyphenatedhyphenationacronym or mboxacronym will prevent hyphenation of acronymmboxtext will also prevent a line break for the complete text

Spacing in Paragraphs

to distinguish paragraphs there are two common wayslindent thebeginning of each paragraph(default latex syle)lto insert vertical space between paragraphs while omitting the indentation (suitable for narrow columns where indenting would cost too much width)

Load the parskip packagelremoves the paragraph indentation completelyl Introduces a skip between paragraphs

documentclassarticleusepackageparskipusepackageurlbegindocumentThe authors of the CTAN team listed ten good reasonsfor using TeX Among them areTeX has the best output ldotsThe original text can be found onurl httpwwwctanorgwhat_is_texhtmlenddocument

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 17: Latex Liyaqat

Changing colors for soul

You can change the strikethrough highlighting and underlineusepackagesoulstHellow worldColorssetstcolorred Makes the strikethrough redsethlcolorgreen Makes the highlight color greensetulcolororange Makes the underline color orange

$X^2$ --Superscript$X_2$ -- Subscript

Text Justification

Environments are necessary to change the standard full justificationthat LATEX uses

Environment EffectCenter Centered textFlushright Right justificationFlushleft Left justification

ExampledocumentclassarticlebegindocumentbegincenterHello worldendcenterenddocument

Other waysraggedright justifies text to rightraggedleft justifies text to leftcenteringtext justifies text to center

creating a narrow text column amp word divisions

Sometimes wed like a paragraph to have a smaller width we would like to put text and a picture side-by-side

parbox[alignment][Hcm][inner alignment]Wcmtext inside column to creates a column Of width W cmOf height Hcm

documentclassarticlebegindocumentparbox3cmTUG is an acronym It means TeX Users Groupenddocument

lhyphenationacro-nym---gt states division points for wordsluserdquousepackage[none]hyphenatrdquolusepackage[htt]hyphenat- enables hyphens

lInner alignmentlcmdashvertically center the text in the boxltmdashplace text at the top of the boxlbmdashplace text at its bottomlsmdashstretch the text vertically if possible

Paragraph Boxes

The text within a paragraph boxworks just like a paragraph exceptthat the author sets thewidthparbox2inThe text within sets the widthYou can accomplish the same thing with the minipageenvironment

Syntaxparboxwidthtext

beginminipagewidthtext

endminipage

Accents and Ellipses

AccentsIf you need accented characters like from a different languageyoursquoll need some special commands

Ellipsestype It was the best of times dotssee It was the best of times

using accents directly

Use package inputenc

Exampledocumentclassarticleusepackage[utf8]inputencbegindocumentNatildeo compreendo Haacute aqui algueacutem que fale inglecircsComment ccedilava Ougrave se trouve laeacuteroportenddocument

inputenc package The option utf8 tells the package to use Unicode inputencoding which provides many more symbols than just the ASCII code

Units of the Document(Breaking Lines)

There are three ways to get a new line of text1 Insert a blank line in the tex file This produces a newparagraph2 Use the command Text after the double backslash willappear on the next line without any indentation (Make sureyou have a space in the tex file after the to achieve this)3 Use newline This functions the same way as Most prefer because of this added functionality

Command Effect[length] creates interline space of length prevents page break after line[length] combination

nolinebreak[length] This command prevents a line break at the current position

An Example

TypeI think we should continuethis conversation [3in] down here

See

I think we should continue this conversation

down hereAcceptable units of measurement in cm pt

Breaking Paragraphs

lWersquove seen that a blank line in your file produces a new paragraphlwe might not want this paragraph indented (It is indented by default)lUse the command noindent before the first line of the next paragraph

documentclassarticlebegindocumentThis is indentednoindent This is notenddocument

Insert the following line into the preamble hyphenationacro-nym tells latex that word acronym has to be hyphenatedhyphenationacronym or mboxacronym will prevent hyphenation of acronymmboxtext will also prevent a line break for the complete text

Spacing in Paragraphs

to distinguish paragraphs there are two common wayslindent thebeginning of each paragraph(default latex syle)lto insert vertical space between paragraphs while omitting the indentation (suitable for narrow columns where indenting would cost too much width)

Load the parskip packagelremoves the paragraph indentation completelyl Introduces a skip between paragraphs

documentclassarticleusepackageparskipusepackageurlbegindocumentThe authors of the CTAN team listed ten good reasonsfor using TeX Among them areTeX has the best output ldotsThe original text can be found onurl httpwwwctanorgwhat_is_texhtmlenddocument

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 18: Latex Liyaqat

Text Justification

Environments are necessary to change the standard full justificationthat LATEX uses

Environment EffectCenter Centered textFlushright Right justificationFlushleft Left justification

ExampledocumentclassarticlebegindocumentbegincenterHello worldendcenterenddocument

Other waysraggedright justifies text to rightraggedleft justifies text to leftcenteringtext justifies text to center

creating a narrow text column amp word divisions

Sometimes wed like a paragraph to have a smaller width we would like to put text and a picture side-by-side

parbox[alignment][Hcm][inner alignment]Wcmtext inside column to creates a column Of width W cmOf height Hcm

documentclassarticlebegindocumentparbox3cmTUG is an acronym It means TeX Users Groupenddocument

lhyphenationacro-nym---gt states division points for wordsluserdquousepackage[none]hyphenatrdquolusepackage[htt]hyphenat- enables hyphens

lInner alignmentlcmdashvertically center the text in the boxltmdashplace text at the top of the boxlbmdashplace text at its bottomlsmdashstretch the text vertically if possible

Paragraph Boxes

The text within a paragraph boxworks just like a paragraph exceptthat the author sets thewidthparbox2inThe text within sets the widthYou can accomplish the same thing with the minipageenvironment

Syntaxparboxwidthtext

beginminipagewidthtext

endminipage

Accents and Ellipses

AccentsIf you need accented characters like from a different languageyoursquoll need some special commands

Ellipsestype It was the best of times dotssee It was the best of times

using accents directly

Use package inputenc

Exampledocumentclassarticleusepackage[utf8]inputencbegindocumentNatildeo compreendo Haacute aqui algueacutem que fale inglecircsComment ccedilava Ougrave se trouve laeacuteroportenddocument

inputenc package The option utf8 tells the package to use Unicode inputencoding which provides many more symbols than just the ASCII code

Units of the Document(Breaking Lines)

There are three ways to get a new line of text1 Insert a blank line in the tex file This produces a newparagraph2 Use the command Text after the double backslash willappear on the next line without any indentation (Make sureyou have a space in the tex file after the to achieve this)3 Use newline This functions the same way as Most prefer because of this added functionality

Command Effect[length] creates interline space of length prevents page break after line[length] combination

nolinebreak[length] This command prevents a line break at the current position

An Example

TypeI think we should continuethis conversation [3in] down here

See

I think we should continue this conversation

down hereAcceptable units of measurement in cm pt

Breaking Paragraphs

lWersquove seen that a blank line in your file produces a new paragraphlwe might not want this paragraph indented (It is indented by default)lUse the command noindent before the first line of the next paragraph

documentclassarticlebegindocumentThis is indentednoindent This is notenddocument

Insert the following line into the preamble hyphenationacro-nym tells latex that word acronym has to be hyphenatedhyphenationacronym or mboxacronym will prevent hyphenation of acronymmboxtext will also prevent a line break for the complete text

Spacing in Paragraphs

to distinguish paragraphs there are two common wayslindent thebeginning of each paragraph(default latex syle)lto insert vertical space between paragraphs while omitting the indentation (suitable for narrow columns where indenting would cost too much width)

Load the parskip packagelremoves the paragraph indentation completelyl Introduces a skip between paragraphs

documentclassarticleusepackageparskipusepackageurlbegindocumentThe authors of the CTAN team listed ten good reasonsfor using TeX Among them areTeX has the best output ldotsThe original text can be found onurl httpwwwctanorgwhat_is_texhtmlenddocument

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 19: Latex Liyaqat

creating a narrow text column amp word divisions

Sometimes wed like a paragraph to have a smaller width we would like to put text and a picture side-by-side

parbox[alignment][Hcm][inner alignment]Wcmtext inside column to creates a column Of width W cmOf height Hcm

documentclassarticlebegindocumentparbox3cmTUG is an acronym It means TeX Users Groupenddocument

lhyphenationacro-nym---gt states division points for wordsluserdquousepackage[none]hyphenatrdquolusepackage[htt]hyphenat- enables hyphens

lInner alignmentlcmdashvertically center the text in the boxltmdashplace text at the top of the boxlbmdashplace text at its bottomlsmdashstretch the text vertically if possible

Paragraph Boxes

The text within a paragraph boxworks just like a paragraph exceptthat the author sets thewidthparbox2inThe text within sets the widthYou can accomplish the same thing with the minipageenvironment

Syntaxparboxwidthtext

beginminipagewidthtext

endminipage

Accents and Ellipses

AccentsIf you need accented characters like from a different languageyoursquoll need some special commands

Ellipsestype It was the best of times dotssee It was the best of times

using accents directly

Use package inputenc

Exampledocumentclassarticleusepackage[utf8]inputencbegindocumentNatildeo compreendo Haacute aqui algueacutem que fale inglecircsComment ccedilava Ougrave se trouve laeacuteroportenddocument

inputenc package The option utf8 tells the package to use Unicode inputencoding which provides many more symbols than just the ASCII code

Units of the Document(Breaking Lines)

There are three ways to get a new line of text1 Insert a blank line in the tex file This produces a newparagraph2 Use the command Text after the double backslash willappear on the next line without any indentation (Make sureyou have a space in the tex file after the to achieve this)3 Use newline This functions the same way as Most prefer because of this added functionality

Command Effect[length] creates interline space of length prevents page break after line[length] combination

nolinebreak[length] This command prevents a line break at the current position

An Example

TypeI think we should continuethis conversation [3in] down here

See

I think we should continue this conversation

down hereAcceptable units of measurement in cm pt

Breaking Paragraphs

lWersquove seen that a blank line in your file produces a new paragraphlwe might not want this paragraph indented (It is indented by default)lUse the command noindent before the first line of the next paragraph

documentclassarticlebegindocumentThis is indentednoindent This is notenddocument

Insert the following line into the preamble hyphenationacro-nym tells latex that word acronym has to be hyphenatedhyphenationacronym or mboxacronym will prevent hyphenation of acronymmboxtext will also prevent a line break for the complete text

Spacing in Paragraphs

to distinguish paragraphs there are two common wayslindent thebeginning of each paragraph(default latex syle)lto insert vertical space between paragraphs while omitting the indentation (suitable for narrow columns where indenting would cost too much width)

Load the parskip packagelremoves the paragraph indentation completelyl Introduces a skip between paragraphs

documentclassarticleusepackageparskipusepackageurlbegindocumentThe authors of the CTAN team listed ten good reasonsfor using TeX Among them areTeX has the best output ldotsThe original text can be found onurl httpwwwctanorgwhat_is_texhtmlenddocument

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 20: Latex Liyaqat

Paragraph Boxes

The text within a paragraph boxworks just like a paragraph exceptthat the author sets thewidthparbox2inThe text within sets the widthYou can accomplish the same thing with the minipageenvironment

Syntaxparboxwidthtext

beginminipagewidthtext

endminipage

Accents and Ellipses

AccentsIf you need accented characters like from a different languageyoursquoll need some special commands

Ellipsestype It was the best of times dotssee It was the best of times

using accents directly

Use package inputenc

Exampledocumentclassarticleusepackage[utf8]inputencbegindocumentNatildeo compreendo Haacute aqui algueacutem que fale inglecircsComment ccedilava Ougrave se trouve laeacuteroportenddocument

inputenc package The option utf8 tells the package to use Unicode inputencoding which provides many more symbols than just the ASCII code

Units of the Document(Breaking Lines)

There are three ways to get a new line of text1 Insert a blank line in the tex file This produces a newparagraph2 Use the command Text after the double backslash willappear on the next line without any indentation (Make sureyou have a space in the tex file after the to achieve this)3 Use newline This functions the same way as Most prefer because of this added functionality

Command Effect[length] creates interline space of length prevents page break after line[length] combination

nolinebreak[length] This command prevents a line break at the current position

An Example

TypeI think we should continuethis conversation [3in] down here

See

I think we should continue this conversation

down hereAcceptable units of measurement in cm pt

Breaking Paragraphs

lWersquove seen that a blank line in your file produces a new paragraphlwe might not want this paragraph indented (It is indented by default)lUse the command noindent before the first line of the next paragraph

documentclassarticlebegindocumentThis is indentednoindent This is notenddocument

Insert the following line into the preamble hyphenationacro-nym tells latex that word acronym has to be hyphenatedhyphenationacronym or mboxacronym will prevent hyphenation of acronymmboxtext will also prevent a line break for the complete text

Spacing in Paragraphs

to distinguish paragraphs there are two common wayslindent thebeginning of each paragraph(default latex syle)lto insert vertical space between paragraphs while omitting the indentation (suitable for narrow columns where indenting would cost too much width)

Load the parskip packagelremoves the paragraph indentation completelyl Introduces a skip between paragraphs

documentclassarticleusepackageparskipusepackageurlbegindocumentThe authors of the CTAN team listed ten good reasonsfor using TeX Among them areTeX has the best output ldotsThe original text can be found onurl httpwwwctanorgwhat_is_texhtmlenddocument

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 21: Latex Liyaqat

Accents and Ellipses

AccentsIf you need accented characters like from a different languageyoursquoll need some special commands

Ellipsestype It was the best of times dotssee It was the best of times

using accents directly

Use package inputenc

Exampledocumentclassarticleusepackage[utf8]inputencbegindocumentNatildeo compreendo Haacute aqui algueacutem que fale inglecircsComment ccedilava Ougrave se trouve laeacuteroportenddocument

inputenc package The option utf8 tells the package to use Unicode inputencoding which provides many more symbols than just the ASCII code

Units of the Document(Breaking Lines)

There are three ways to get a new line of text1 Insert a blank line in the tex file This produces a newparagraph2 Use the command Text after the double backslash willappear on the next line without any indentation (Make sureyou have a space in the tex file after the to achieve this)3 Use newline This functions the same way as Most prefer because of this added functionality

Command Effect[length] creates interline space of length prevents page break after line[length] combination

nolinebreak[length] This command prevents a line break at the current position

An Example

TypeI think we should continuethis conversation [3in] down here

See

I think we should continue this conversation

down hereAcceptable units of measurement in cm pt

Breaking Paragraphs

lWersquove seen that a blank line in your file produces a new paragraphlwe might not want this paragraph indented (It is indented by default)lUse the command noindent before the first line of the next paragraph

documentclassarticlebegindocumentThis is indentednoindent This is notenddocument

Insert the following line into the preamble hyphenationacro-nym tells latex that word acronym has to be hyphenatedhyphenationacronym or mboxacronym will prevent hyphenation of acronymmboxtext will also prevent a line break for the complete text

Spacing in Paragraphs

to distinguish paragraphs there are two common wayslindent thebeginning of each paragraph(default latex syle)lto insert vertical space between paragraphs while omitting the indentation (suitable for narrow columns where indenting would cost too much width)

Load the parskip packagelremoves the paragraph indentation completelyl Introduces a skip between paragraphs

documentclassarticleusepackageparskipusepackageurlbegindocumentThe authors of the CTAN team listed ten good reasonsfor using TeX Among them areTeX has the best output ldotsThe original text can be found onurl httpwwwctanorgwhat_is_texhtmlenddocument

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 22: Latex Liyaqat

using accents directly

Use package inputenc

Exampledocumentclassarticleusepackage[utf8]inputencbegindocumentNatildeo compreendo Haacute aqui algueacutem que fale inglecircsComment ccedilava Ougrave se trouve laeacuteroportenddocument

inputenc package The option utf8 tells the package to use Unicode inputencoding which provides many more symbols than just the ASCII code

Units of the Document(Breaking Lines)

There are three ways to get a new line of text1 Insert a blank line in the tex file This produces a newparagraph2 Use the command Text after the double backslash willappear on the next line without any indentation (Make sureyou have a space in the tex file after the to achieve this)3 Use newline This functions the same way as Most prefer because of this added functionality

Command Effect[length] creates interline space of length prevents page break after line[length] combination

nolinebreak[length] This command prevents a line break at the current position

An Example

TypeI think we should continuethis conversation [3in] down here

See

I think we should continue this conversation

down hereAcceptable units of measurement in cm pt

Breaking Paragraphs

lWersquove seen that a blank line in your file produces a new paragraphlwe might not want this paragraph indented (It is indented by default)lUse the command noindent before the first line of the next paragraph

documentclassarticlebegindocumentThis is indentednoindent This is notenddocument

Insert the following line into the preamble hyphenationacro-nym tells latex that word acronym has to be hyphenatedhyphenationacronym or mboxacronym will prevent hyphenation of acronymmboxtext will also prevent a line break for the complete text

Spacing in Paragraphs

to distinguish paragraphs there are two common wayslindent thebeginning of each paragraph(default latex syle)lto insert vertical space between paragraphs while omitting the indentation (suitable for narrow columns where indenting would cost too much width)

Load the parskip packagelremoves the paragraph indentation completelyl Introduces a skip between paragraphs

documentclassarticleusepackageparskipusepackageurlbegindocumentThe authors of the CTAN team listed ten good reasonsfor using TeX Among them areTeX has the best output ldotsThe original text can be found onurl httpwwwctanorgwhat_is_texhtmlenddocument

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 23: Latex Liyaqat

Units of the Document(Breaking Lines)

There are three ways to get a new line of text1 Insert a blank line in the tex file This produces a newparagraph2 Use the command Text after the double backslash willappear on the next line without any indentation (Make sureyou have a space in the tex file after the to achieve this)3 Use newline This functions the same way as Most prefer because of this added functionality

Command Effect[length] creates interline space of length prevents page break after line[length] combination

nolinebreak[length] This command prevents a line break at the current position

An Example

TypeI think we should continuethis conversation [3in] down here

See

I think we should continue this conversation

down hereAcceptable units of measurement in cm pt

Breaking Paragraphs

lWersquove seen that a blank line in your file produces a new paragraphlwe might not want this paragraph indented (It is indented by default)lUse the command noindent before the first line of the next paragraph

documentclassarticlebegindocumentThis is indentednoindent This is notenddocument

Insert the following line into the preamble hyphenationacro-nym tells latex that word acronym has to be hyphenatedhyphenationacronym or mboxacronym will prevent hyphenation of acronymmboxtext will also prevent a line break for the complete text

Spacing in Paragraphs

to distinguish paragraphs there are two common wayslindent thebeginning of each paragraph(default latex syle)lto insert vertical space between paragraphs while omitting the indentation (suitable for narrow columns where indenting would cost too much width)

Load the parskip packagelremoves the paragraph indentation completelyl Introduces a skip between paragraphs

documentclassarticleusepackageparskipusepackageurlbegindocumentThe authors of the CTAN team listed ten good reasonsfor using TeX Among them areTeX has the best output ldotsThe original text can be found onurl httpwwwctanorgwhat_is_texhtmlenddocument

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 24: Latex Liyaqat

An Example

TypeI think we should continuethis conversation [3in] down here

See

I think we should continue this conversation

down hereAcceptable units of measurement in cm pt

Breaking Paragraphs

lWersquove seen that a blank line in your file produces a new paragraphlwe might not want this paragraph indented (It is indented by default)lUse the command noindent before the first line of the next paragraph

documentclassarticlebegindocumentThis is indentednoindent This is notenddocument

Insert the following line into the preamble hyphenationacro-nym tells latex that word acronym has to be hyphenatedhyphenationacronym or mboxacronym will prevent hyphenation of acronymmboxtext will also prevent a line break for the complete text

Spacing in Paragraphs

to distinguish paragraphs there are two common wayslindent thebeginning of each paragraph(default latex syle)lto insert vertical space between paragraphs while omitting the indentation (suitable for narrow columns where indenting would cost too much width)

Load the parskip packagelremoves the paragraph indentation completelyl Introduces a skip between paragraphs

documentclassarticleusepackageparskipusepackageurlbegindocumentThe authors of the CTAN team listed ten good reasonsfor using TeX Among them areTeX has the best output ldotsThe original text can be found onurl httpwwwctanorgwhat_is_texhtmlenddocument

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 25: Latex Liyaqat

Breaking Paragraphs

lWersquove seen that a blank line in your file produces a new paragraphlwe might not want this paragraph indented (It is indented by default)lUse the command noindent before the first line of the next paragraph

documentclassarticlebegindocumentThis is indentednoindent This is notenddocument

Insert the following line into the preamble hyphenationacro-nym tells latex that word acronym has to be hyphenatedhyphenationacronym or mboxacronym will prevent hyphenation of acronymmboxtext will also prevent a line break for the complete text

Spacing in Paragraphs

to distinguish paragraphs there are two common wayslindent thebeginning of each paragraph(default latex syle)lto insert vertical space between paragraphs while omitting the indentation (suitable for narrow columns where indenting would cost too much width)

Load the parskip packagelremoves the paragraph indentation completelyl Introduces a skip between paragraphs

documentclassarticleusepackageparskipusepackageurlbegindocumentThe authors of the CTAN team listed ten good reasonsfor using TeX Among them areTeX has the best output ldotsThe original text can be found onurl httpwwwctanorgwhat_is_texhtmlenddocument

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 26: Latex Liyaqat

Spacing in Paragraphs

to distinguish paragraphs there are two common wayslindent thebeginning of each paragraph(default latex syle)lto insert vertical space between paragraphs while omitting the indentation (suitable for narrow columns where indenting would cost too much width)

Load the parskip packagelremoves the paragraph indentation completelyl Introduces a skip between paragraphs

documentclassarticleusepackageparskipusepackageurlbegindocumentThe authors of the CTAN team listed ten good reasonsfor using TeX Among them areTeX has the best output ldotsThe original text can be found onurl httpwwwctanorgwhat_is_texhtmlenddocument

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 27: Latex Liyaqat

Breaking Pages

This command is exactly what you might expect nownewpageEverything after this command will appear on the next page Thatnew paragraph will be indented

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 28: Latex Liyaqat

Spaces(Horizontal Space)

Wersquove learned about and as ways to add horizontal spaceWersquoll mainly use the hspace commandCommand Resultquad | |qquad | |hspace8pt | |hspace6in | |hspace12cm | |Horizontal space can be negative if needed

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 29: Latex Liyaqat

Vertical Space

The analog to hspace is vspaceLATEX adds vertical space after the typeset line in which thatcommand appearsThis means that vspace commands should usually be on theirown line in the tex file

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 30: Latex Liyaqat

Filling Space

hfill fills available space in the line with blank spacefills upto extreme right vfill fills available space on the page with blank spacefills upto bottom

Exampledocumentclassarticlebegindocumentnoindent The top [1in]The left hfill and the rightvfillThe bottomenddocument

Framed Boxes (Boxes arround the text)

An added text effect can be achieved by framing text

fboxLike thisRestriction You cannot break a line within fbox

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 31: Latex Liyaqat

Designing pages

lAdjust the marginslChange the line spacinglSection the documentlCreate a table of contentslDesign headers and footerslControl page breakinglSet footnotes and modify their appearance

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 32: Latex Liyaqat

Designing pages

Document propertiesparameters

lSize of the document(margins)lFont size fore text inside the documentlClass of document(bookletter etc)lLanguage of documentlChapter structure and numberinglHeader and footerslPage numbers

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 33: Latex Liyaqat

Designing pages

Exampledocumentclass[a4paper12pt]bookusepackage[english]babelusepackageblindtextbegindocumentchapterExploring the page layoutIn this chapter we will study the layout of pagessectionSome filler textblindtextsectionA lot more filler textMore dummy text will followsubsectionPlenty of filler textblindtext[10]enddocument

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 34: Latex Liyaqat

specifying margins and paper size

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

This package takes care of our layout regarding the paper size margins and more dimensions

lpaper=a4paper(letterpaper executivepaper legalpaper a0paper a6paperlb0paper b6paper and more)lpaperwidth=7inlpaperheight=10inlpapersize=7in10in(papersize=widthheight)lLandscape or portrait(default)

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 35: Latex Liyaqat

Specifying the text area

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

The text area may be adjusted by these optionsltextwidth sets the width of the text area like textwidth=140mml textheight states the height of the text area like textheight=180mm

llines gives another way to specify the text height by the number of lines likellines=25lincludehead causes the header of the page to be included into the body arealset false by defaultlincludefoot causes the footer of the page to be included into the body arealset false by default

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 36: Latex Liyaqat

Setting the margins

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

size of the visible margins can be specified by these options

lleft right set the width of the left and the right margin like left=2cmlUse it for one-sided documentslinner outer set the width of the inner and the outer margin like inner=2cmlUse it for two-sided documentsltop bottom set the height of the top and the bottom margin like top=25mmltwoside switches to two-sided mode This means that left and right marginslwould be swapped on left-hand pages also called verso pageslbindingoffset reserves space on the left margin (one-side) respectively thelinner margin (two-sided) for the bindinglusepackage[margin=3cm]geometrywill result in a 3 cm margin on each edge of the paper

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 37: Latex Liyaqat

increasing line spacing

setspace package adjusts the line spacingusepackage[onehalfspacing]setspacelOnehalfspacingincreases the spacing by half of a line height for thelwhole document lsinglespacing is the default No additional space will be inserted ldoublespacing for even more spacing the distance between thelbaselines of successive text lines would be twice as high as a single line

above shouldnt be nested

For the need of a different stretching factor the spacing environment is provided

beginspacing24This text is stretched by a factor of 24endspacing

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 38: Latex Liyaqat

two-column document

documentclass[a4paper12ptlandscapetwocolumn]book

Twocolumncauses the body text to be divided into two columns

twocolumn[opening text] starting a two-column page with optional opening text over the whole width

onecolumn begins a one-column page

titlepage or notitlepage The first causes a separate title page whenmaketitle is used and is the default except for the article class Thedefault of article is notitlepage which means that normal text may followthe title on the same page fleqn Causes displayed formulas to be left-aligned leqno For numbered displayed formulas the number would be put to the left sideThe right side is the default

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 39: Latex Liyaqat

Creating a table of contents

tableofcontents tells LaTeX to produce a file with the extension tocbullentries are created by the sectioning commands

shortening the table of content entriessectiontitle creates non numbered sections

documentclass[a4paper12pt]bookusepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometrybegindocumenttableofcontentschapter[Page layout]Exploring the page layoutIn this chapter we will study the layout of pagessection[Filler text]Some filler textblindtextsection[More]A lot more filler textMore blindtext will followsubsection[Plenty]Plenty of filler textblindtext[10]enddocument

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 40: Latex Liyaqat

Designing headers and footers

lDefault shape of the page headings is slanted( are written in capital)luse bold typeface instead and ( use capital letters only for the chapter title )lload the fancyhdr package and use its commands to achieve thatlStep 1 call the fancyhdr by command fancyhf

command fancyhead[optional argument] argument2(command)

Argument2lleftmark Used by the book class to store the chapter title together with thelchapter number Capital letters are used as defaultlrightmark Used by the book class to store the section title together with itslnumber Capital letters are used as well

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 41: Latex Liyaqat

Designing headers and footers

command fancyhead[optional argument] argument2(command)Optional argumentsRE Right evenRO Right oddLE Left evenLO Left oddArgument2 can belrightmarklleftmark

lfancyfoot to display the page number in the footerlLE and RO that showed the page number on even as well as on odd pageslcommand thepage prints the page numberlAll those commands are used to modify a page style provided by fancyhdrlthis style is called fancylTell LaTeX to use this style by command pagestylefancy

exampleusepackagefancyhdrfancyhffancyhead[LE]leftmarkfancyhead[RO]nouppercaserightmarkfancyfoot[LERO]thepagepagestylefancybegindocument

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 42: Latex Liyaqat

Understanding page styles

LaTeX and its base classes provide four page styleslempty Neither a header nor a footer is shownlplain No header The page number will be printed and centered in the footerlheadings The header contains titles of chapters sections andor subsectionsldepending on the class and also the page number The footer is emptylmyheadings The header contains a user-defined text and the page numberlthe footer is emptyllfancyhdr adds one page stylelfancy Both the header and footer may be customized by the user

lTwo commands may be used to choose the page stylelpagestylename Switches to the page style name from this point onwardslthispagestylename Chooses the page style name only or the current pagelthe following pages will have the style thats been used before

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 43: Latex Liyaqat

Customizing header and footer

Divide into 6 peices left center and right (l c r)lFor the header lhead chead rheadlFor the footer lfoot cfoot rfootExample cheadUsers guidecfootthepage

Alternativelywe can use these versatile commandslFor the header fancyhead[code]textlFor the footer fancyfoot[code]text

Symbol MeaningL leftC centerR rightE even pageO odd pageH headerF footer

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 44: Latex Liyaqat

Using decorative lines in header or footer

renewcommandcan introduce or delete lines between header and body text and body text and footerrenewcommandheadrulewidthwidth renewcommandfootrulewidthwidthwidth may be a value like 1pt 05mmdefault is 04pt for the header line and 0pt for the footer line

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 45: Latex Liyaqat

inserting page breaks

lpagebreak causes a page break (stretches the text)lnewpage breaks the page l but it doesnt stretch the textlpagebreak behaves like linebreak and newpage works like newlinelnopagebreak thats analogous to nolinebreak and forbids page breaking

lIf you use the two-column format both pagebreak and newpage would begin on a newlcolumn instead of a new pagelclearpage works like newpage except that it will start on a new pageleven in two-column modelcleardoublepage does the same but causes the following text to startlon a right-hand page inserting a blank page if necessary The latter is usefullfor two-sided documents

lEnlarging a page if text exceeds little bitlUse command after subsection in examplelenlargethispagebaselineskip

EXAMPLEdocumentclass[a4paper11pt]book

usepackage[english]babelusepackageblindtext

usepackage[a4paper inner=15cm outer=3cm top=2cmbottom=3cm bindingoffset=1cm]geometry

begindocumentchapterExploring the page layout

In this chapter we will study the layout of pagessectionSome filler text

blindtextsectionA lot more filler textMore dummy text will follow

subsectionPlenty of filler textblindtext[3]

enddocument

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 46: Latex Liyaqat

Using footnotes in text and in headings

lInsert one footnote in the body textlMore dummy textfootnoteserving as a placeholder will followlone in a section headinglsectionA lot more filler textprotectfootnoteto fill the page

l command footnotetext places a superscripted number at the current positionlamp it prints its argument text into the bottom of the pagelIn the Section headingfootnote command has been preceded by the command protect lIf omitted it an error(processing error) would be raisedlprotect simply prevents this processing errorlUsing Footnotes simply in headingslbe aware that they would appear in the table of contentsamp perhaps also in page headerslHow to solve itluse the optional parameterlsection[title without footnote]title with footnote

lSame applies to chapter

lfootnotemark[number] produces a superscripted number in the text as a footnote marklfootnotetext[number]text generates a footnote without putting a footnote mark into lthe text

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 47: Latex Liyaqat

Building a bulleted list(itemsize environment)

LATEX provides three list environments itemsize enumerate anddescriptionWithin each environment item gives you the next item Alsoitem must be the first thing in the environment

Some things to notice about the itemize environmentbull It is a list with bullet pointsbull It has no numbers

beginitemizeitem It is a list with bullet pointsitem It has no numbersenditemize

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 48: Latex Liyaqat

The enumerate Environment(numbered list)

Things about the enumerate environment1 It also produces a list2 It enumerates the listbeginenumerateitem It also produces a listitem It enumerates the listendenumerate

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 49: Latex Liyaqat

The description Environment

The description environment is generally used for statingdefinitionsSpanish The language spoken in SpainFrench The language spoken in France

Examplebegindescriptionitem[Spanish] The language spoken in Spainitem[French] The language spoken in Franceenddescription

Note the optional argument is the whole point here

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 50: Latex Liyaqat

Nesting Lists

It is easy to nest the listing environments1 This is the first level in enumerate(a) This is the second level

beginenumerateitem This is the first level

beginenumerateitem This is the second levelendenumerate

endenumerateThis can be done with itemize as well

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 51: Latex Liyaqat

Customizing itemize

The standard ldquobulletsrdquo that come in the itemize environment aredictated by the document class that you use

l Here is the first level

- Here is the second level Here is the third level

These symbols can be changed on a case-by-case basis

⋆ This item begins with a stardagger This item begins with a daggeritem[$star$]item[$dagger$]

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 52: Latex Liyaqat

Saving space with compact lists

lThere is a lot of white space white space around the list itemslit may be required to use another scheme for the enumeration for the bullets modify the line spacing indentationlThere are packages helping us both to save space and to customize the symbolslWe shall remove the white space around the list items and before and after the whole listlUse the package paralist lReplace enumerate with compactenum and itemize with compactitem

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 53: Latex Liyaqat

List in single paragraph

l package paralist provides several new list environments designed to beltypeset within paragraphslvery compact looklenumerated list typeset within a paragraph

Exampleitem by using the setspace package and one of its options

begininparaenumitem singlespacing

item onehalfspacingitem double spacing

endinparaenum

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 54: Latex Liyaqat

Commands in paralist package

lFor each standard environment paralist adds three corresponding environments

lNumbered listsl compactenum Compact version of the enumerate environment without any

vertical space before or after the list or its items

l inparaenum An enumerated list typeset within a paragraphl asparaenum Every list item is formatted like a separate common LaTeX

paragraph but numberedlBulleted lists

l compactitem Compact version of the itemize environment like compactenum inparaitem An itemized list typeset within a paragraph rarely seen in print

l asparaitem Like asparaenum but with symbols instead of numbers

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 55: Latex Liyaqat

Modifying lists using enumitem package

lchange the numbering schemelnumbering alphabetically using circled letterslreplace bullets by dashes

ldiscard paralist and load the package enumitem insteadlmention properties of the list and the items using some set of commandslDefine these commands in the preamble

usepackageenumitemsetlistnolistsepsetitemize[1]label=---setenumerate[1]label=textcircledscriptsizeAlphfont=sffamily

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 56: Latex Liyaqat

Modifying lists using enumitem package

lUsed commands to specify list propertieslsetlistnolistsep setlist sets properties valid for all types of lists nolistsep achieves very compact lists analogous to the compact paralist environmentlsetitemize[1]label=ndash-- setitemize modifies properties of bulleted listsused an em dash as the label to get a leading wide dashlsetenumerate[1]label=textcircledscriptsizeAlphfont=sffamily setenumerate sets properties valid for numbered lists We used it to set a label and a font for the label The command Alph stands for enumeration in capital letters

loptions may be set globally like setenumerate[level]key=value listloptions may be used locally like we did with resume lMore examples arel beginitemize[noitemsep] for a compact bulleted listl beginenumerate[label=Romanstart=3] numbered by III IV l beginenumerate[label=alph)]nolistsep] for a very compact list numbered a) b) c)

arabic 1 2 3 4 alph a b c d Alph A B C D roman i ii iii iv Roman I II III IV

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 57: Latex Liyaqat

using the tabbing environment

A table is generated by the tabbing or tabular environmentLATEX treats the table as one big symbolConsequencesbull Tables (usually) cannot stretch across pagesbull Usually tables should be displayed like in the center environmentThe syntax for tabbing

begindocumentbegintabbing= Software = = LaTeX [= sets tab positions]gt Author gt gt Leslie Lamport [= goes to the next tab stop]gt Website gt gt wwwlatex-projectorgendtabbingenddocument

Inside tabbing declarations are local to the current item = gt or kill command would stop the effectTabbing environments cannot be nested

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 58: Latex Liyaqat

Tables()

A table is generated by the tabular environmentTables using tabular environment can be nestedThe syntax for tabularbullbegintabularcolumn specifications[eg begintabularcc]bulltable cells separate columns with amp [headCommand amp headDeclaration ]bullseparate rows with bulldraw horizontal lines with hlinebullendtabular

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 59: Latex Liyaqat

Drawing lines in tables Column Specifications

bullFor each column you type l c or r depending on the justification you wantbull You can put in lines between columns with |

begincenterbegintabular|l|c|r|p17cm|hlineleft amp centered amp right amp a fully justified paragraph cellhlinel amp c amp r amp phlineendtabularendcenter

bullpwidth for a paragraph cell of a certain widthbull| stands for a vertical line

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 60: Latex Liyaqat

More Control

Instead of hline the command cline1-2 draws ahorizontal line through columns 1 and 2 only (for example)

begincenterbegintabular|l|r|c|hlineduck amp vulture amp goose cline1-2humming bird amp bee amp eagle hlineendtabularendcenter

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 61: Latex Liyaqat

Even More Control

The command multicolumn in tables allows you to stretch anentry across columns

begintabular|l|r|c|hlineduck amp vulture amp goose hlinehumming bird amp multicolumn2c|bee hlineendtabularSyntaxmulticolumn1231 mdash number of columns to span2 mdash alignment of the new super-column3 mdash text of column

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 62: Latex Liyaqat

Justifying Single Cells

We saw how to put different justifications on different columns withina table (or array) What I didnrsquot show you was how to change thejustification for a single cell This is often used for table headingsbegintabular|l|l| hlinewords amp words hlinelonger words amp longer words hlinemulticolumn1|c|word amp word hlineendtabular

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 63: Latex Liyaqat

More Column Specifications

Within the tabular environment so far we know the columncommands l c and r Two more are provided by defaultbull psize mdash This makes a column of a fixed width Everythingin that column is left justified Entries in other rows are justifiedvertically at the top of the cellbull command mdash This is a way of putting commands betweencolumns

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 64: Latex Liyaqat

Column Width Example

Note the difference

begintabular|l|c| hlinebegintabular|p15in|c| hline

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 65: Latex Liyaqat

Intercolumn Command Example

The command is especially useful when you want to alignalong decimal points Notice

begintabular|c|rl| hlineA nice number amp 2amp5177 hlineA better number amp 3amp14 hlineA super number amp 554amp8 hlineendtabular

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 66: Latex Liyaqat

Extra Column Specifiers

If you load the array package in your preamble you get two othercolumn specifiersbull msize mdash The same as psize except other entries in the row are vertically center justifiedbull bsize mdash The same as psize except other entries in the row are vertically bottom justified

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 67: Latex Liyaqat

Changing the Line Thickness

Sometimes yoursquod like a thicker line width in your tables (default is04 pt) We can change the arrayrulewidth to do this

setlengtharrayrulewidth2ptbegintabular|l|r| hlineleft amp right hlineleft left amp right right hlineendtabularNote This will make a ldquoglobalrdquo change unless it is inside of someenvironment One solution is to put before setlength and after endtabular

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 68: Latex Liyaqat

The multirow Package

With usepackagemultirow in your preamble you can haveentries that span multiple rows just the same way that we can haveentries that span multiple columns nowmultirownrowswidthcontentsnrows number of rows to spanwidth width of entry can type contents contents of the entry

begintabular|l|l|l| hlineone amp two amp multirow2three cline1-2four amp five amp hline

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 69: Latex Liyaqat

Tables on Multiple Pages

We said before that a table could not be split across pages Withoutextra packages thatrsquos true We can make it happen with thesupertabular package

Since this splits tables across pages it has a way to specify thetable header that shows up on every page

tableheadrowsmdash repeated on every pagetablefirstheadrowsmdash table header for only first pagetabletailrowsmdash repeated on every pagetablelasttailrowsmdash table footer for only last page

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 70: Latex Liyaqat

Math Formulas

There are two types of math (or formulas) inline mdash the formula is part of the current line or paragraph displayed mdash on a separate line (or lines) with spacing that setsit apart

Inline FormulasUse dollar signs to surround a formula like 2 + 2 = 4Use dollar signs to surrounda formula like $2+2=4$Displayed FormulasUse the symbols [ and ] to enclose a formula like

2 + 2 = 4 to enclose a formula like [ 2+2=4 ]Typing $ or [ sends LATEX into math mode Some of the behavior isdifferent in this mode so be careful

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 71: Latex Liyaqat

An Example

Let f be the function f(x) = x2 This means that f(2) = 4 andf(minus3) = 9

Let $f$ be the function $f(x)=x^2$This means that $f(2)=4$ and [ f(-3)=9 ]

Note 1 Remember that formulas are part of your writing sopunctuation rules need to be observed

Note 2 [ and ] are shortcuts for begindisplaymath andenddisplaymath

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 72: Latex Liyaqat

Spacing in Math Mode

LATEX treats multiple spaces as one The following give the sameoutput2+2=42 + 2 =4

The spacing after a comma is different in math and text Unless thecomma is part of the mathematical notation you generally want itoutside of math modeExample To write x = a b or c type

$x=a$ $b$ or $c$

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 73: Latex Liyaqat

The amsmath package

Some of what follows requires the amsmath package to be loadedin your preamble So just to be safe includeusepackageamsmathin your preamble from now onHerersquos a good template for our class at this point

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathbegindocumentenddocument

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 74: Latex Liyaqat

Equations

The equation environment is the same as the displaymathenvironment except each equation environment is numberedThe quadratic formula is

No blank lines are allowed in an equation environmentThe equation environment is the same as displaymathor [ and ](A good rule of thumbmdashthe starred version of an environmentsuppresses the numbering)

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 75: Latex Liyaqat

Fractions

Fractions are only slightly different than the other mathematicaloperatorsTo see this you need to type this frac2+x6-y

We can use dfrac to fix that inlineYou know

You know $dfrac2+x6-y$ is my favorite ldotsIf you want the (smaller) inline-sized fraction in display mode usetfrac

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 76: Latex Liyaqat

Subscripts and Superscripts

The ldquocaretrdquo ^ is used for superscripts and the underscore _ is used for subscriptsType Display$x^2$ x2$x_7$ x7$x^10$ x10$x_17$ x17Note that if your subscript or superscript is more than one characteryoursquoll need to enclose it in braces

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 77: Latex Liyaqat

Roots

The square root sign is made with a command in math mode$sqrt51$ produces radic51This is used for all kinds of roots not just square roots$sqrt[3]5$ produces 3radic 5$sqrt[10]44$ produces 10radic 44

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 78: Latex Liyaqat

Text in Math

Text in math is produced with the text commandArea of a rectangle = l w

beginequationtextArea of a rectangle = lcdot wendequation

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 79: Latex Liyaqat

Symbols(Greek Letters)

Greek letters are needed frequently within formulas like

within formulas like [ A = pi r^2 ]You can find a list of the permitted Greek letters in a table on ourweb site LATEX can do some of the Greek capitals but not all ofthemA lot of these are easy to guess

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 80: Latex Liyaqat

Integral Signs

This is a mathematics-specific symbol but it illustrates a largerpoint Consider this formula

formula [ int_2^15 x^2dx ]There are lots of integral symbols available

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 81: Latex Liyaqat

Delimiters

A delimiter is simply a special math symbol to enclose part of aformula The parentheses in the following formula are an exampleof delimiters

There are all sorts of delimiters available

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 82: Latex Liyaqat

Stretching Delimiters

Sometimes delimiters do not extend up and down enough to fullyenclose whatrsquos inside You can see that here

Instead we should have

The left and right commands can be applied to most delimiters

left and right accomplish this for you

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 83: Latex Liyaqat

Specifying Delimiter Height

Instead of trusting LATEX to give your delimiter the correct size youcan specify it yourself in some cases

( big( Big( bigg( Bigg(The analogs for right delimiters exist too and these can be appliedto most delimitersExample in integral problems you need to write

right| isnrsquot big enough so I use Bigr|_a^b

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 84: Latex Liyaqat

Operators

An operator in LATEX is a log-like function like sin or lnTo get sin x you cannot type $sin x$ or sin $x$ You must type$sin x$Another kind of operator is lim This is called an operator with limitsbecause it is frequently used like this

For this reason operators like sin are called operators without limits

You can fake display mode with displaystyleType $displaystyle lim_x to 1 f(x)$

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 85: Latex Liyaqat

Tables of Operators

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 86: Latex Liyaqat

Large Operators

The symbols for sums and products are examples of symbols which have different sizes depending on whether they are typeset inline or in a displayed environment

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 87: Latex Liyaqat

Aligned Formulas

When you want to consider multiple formulas or equations at onceyou need a nice way to put math on multiple lines The simplestsetup here is when you have a point to line up in the equations

beginaligna^2 + b^2 amp= c^2 a+b amp= c + 2endalignUse amp as your alignment point and as the line separatorThe align environment will align without equation numbers

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 88: Latex Liyaqat

Multiple Aligned Columns

The align environment aligned things in one column Thealignat environment allows alignment of multiple columns andcontrol over the intercolumn space

beginalignat2f(x) amp= x^2 qquad amp g(x) amp= 2x-1 f(2) amp= 4 amp g(2) amp= 3endalignatThe mandatory argument is the number of aligned columnsIn this example the first and third amp give the alignment points thesecond amp begins the second column In general even-numberedamprsquos are column separators and odd-numbered amprsquos are alignmentpoints

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 89: Latex Liyaqat

Matrices

Matrices function like tables except everything is in math modeConsequently you must enter math mode before entering amatrix environment

[beginmatrixa-2 amp b amp x+y-z 4 amp e+f amp 0endmatrix]Within the matrix environment all columns are centered Alsothere are no delimiters on either side of the matrix

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 90: Latex Liyaqat

More Matrices

We can enclose a matrix in delimiters in the expected way

[left(beginmatrixa amp b+c d-e amp 2endmatrixright)]The delimiters do not have to match

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 91: Latex Liyaqat

Variant Matrix Environments

LATEX provides environments for matrices with the most commondelimiters

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 92: Latex Liyaqat

Arrays

The major difference between the various matrix environmentsand the array environment is that you have a lot more controlwithin array

[beginarray|l|r| hlinea+b amp d hlinee amp f+2 hlineendarray]array is just like tabular except in math mode If you want anymulticolumns you must use array instead of matrixYou can put delimiters around array environments too

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 93: Latex Liyaqat

Cases

The cases environment is the way to denote a piecewise-definedfunction It is really a special type of matrix

[|x| =begincases-x amp xlt0 x amp x ge 0endcases]The cases environment can appear inline or displayed

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 94: Latex Liyaqat

Document Layout (Page Styles)

LATEX provides several standard page styles In the preamble usepagestylestyle where style is one of the followingplain blank header footer contains only the page numberempty empty header and footerheadings header provided by document class empty footermyheadings header determined by markright andmarkboth footer is emptymarkright takes one argument markboth takes twoargumentsmdashthe left-hand page header and the right-hand pageheader Wersquoll only need markright usuallythispagestylestyle changes only the headersfooter on thatpage

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 95: Latex Liyaqat

An Example of Page Styles

Letrsquos play around with thisdocumentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestylemyheadingsbegindocumentHellomarkrightMath 233newpageGoodbyemarkrightIntroduction to Scientific TypesettingenddocumentTry to substitute plain and empty for myheadings Also try touse thispagestyle on the second page

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 96: Latex Liyaqat

Sections of an Article

Each document class has its own division names For the articleclass the divisions aresection subsection subsubsectionThe general form of the command is sectiontitleA variant is section[short-title]title In this case short-title isused in the running headerA second variant is sectiontitle where no section number isprinted and nothing is carried in the running header

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 97: Latex Liyaqat

An Example

documentclassarticleusepackage[margin=1in]geometryusepackageamsmathpagestyleheadingsbegindocumentsection[Intro]IntroductionInformation heresubsectionGetting StartedRight hereenddocument

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 98: Latex Liyaqat

Title

For scholarly articles the title has a special appearance Thisshould be the first item after begindocument when writingsuch an articleIn the article class there are several fields possible then themaketitle command formats the title (The title page generallyhas the plain page style)begindocumenttitleA Really Nice PaperauthorRyan Higginbottomdatetodaymaketitle

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 99: Latex Liyaqat

Abstracts

The abstract environment typesets the abstract of the paperThis goes within the document environmentMake sure to put the abstract environment after the maketitle command

begindocumenttitleauthordatemaketitlebeginabstractendabstract

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 100: Latex Liyaqat

Bibliography

Most papers will require a bibliography or ldquoReferencesrdquo section ofsome sort This will be the last thing in the body of your paper andit falls in a thebibliography environmentbeginthebibliographybibitemkeyendthebibliography should be 9 or 99 depending on the number of entries you haveYou will have to run LATEX twice to get the citations correct

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 101: Latex Liyaqat

More on Bibliographies

Reference to the bibliography is done with citekey Yoursquollnotice in the sample file that Irsquove also put an optional page referenceinTwo downsides to processing bibliographies this way you areresponsible for the formatting of the entry and you are responsiblefor the order in which entries appearIn TeXnicCenter open the second example file (tex) I posted onSakai build it twice to PDF and view it

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 102: Latex Liyaqat

Table of Contents

Longer articles usually have tables of contents This is generatedwith the tableofcontents command Because of the way LATEXprocesses things it will take at least 2 (and sometimes 3) runs ofLATEX to get all of the entries and page numbers correctTake the previous example tex file and add three lines directlyafter begindocumenttableofcontentssectionIntroductionsubsectionGetting StartedNow build three times and look at the pdf file

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 103: Latex Liyaqat

The TOC Example

Notice that the ldquoReferencesrdquo wasnrsquot in the table of contents We canadd it (or anything else) manuallyaddcontentslinetocsectiontext to be addedFrom the previous example put newpage before thethebibliography environment and typeaddcontentslinetocsectionReferencesafter newpageBuild three times and view

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 104: Latex Liyaqat

More Header customization(The fancyhdr package)

We saw earlier that there were a few ways to adjust the page styleof your document The fancyhdr package gives you a ton morecontrolThe commands for this go in the preamble of your document

fancypagestylenamelhead chead rheadlfoot cfoot rfootrenewcommandheadrulewidth0ptrenewcommandfootrulewidth0ptpagestylename

Within the fancypagestyle command typing thepage willgive the page number

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 105: Latex Liyaqat

Counters

Counters are what LATEX uses to keep the right number attached toequations pages theorems etc Herersquos a list of the standardcounters

equation figure footnotePage table chapterSection subsection subsubsectionEnumi enumii enumiiiEnumiv

For every counter name there is a command thename whichshows the current value of the name counter (Wersquove seen thisalready when using thepage)

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 106: Latex Liyaqat

Setting Counters

The main command here is setcountername where isthe value you wish to assign to the counter called nameIf you want the first equation in your paper numbered 8 for somereason you should put this line directly before the equationenvironmentsetcounterequation7For most counters LATEX increments the counter and then generatesthe appropriate number The only exception is with the pagecounter If you want the first page in your paper to be page 45 youshould put this line directly after begindocumentsetcounterpage45

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 107: Latex Liyaqat

Advancing Counters

To increment a counter by one usestepcounternamewhere name is the title of some counterTherersquos also the command addtocountercounternumHere num should be an integer and counter should be arecognized counterOpen the first example file (tex) build to PDF and view

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 108: Latex Liyaqat

A Theorem Example

Theorem 1 In a right triangle with sides a b and c the equationa2 + b2 = c2 holdsbegintheoremIn a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheoremThere is also an optional way to give names to theoremsTheorem 2 (The Pythagorean Theorem) In a right triangle withsides a b and c the equation a2 + b2 = c2 holdsbegintheorem[The Pythagorean Theorem]In a right triangle with sides $a$ $b$and $c$ the equation $a^2+b^2=c^2$ holdsendtheorem

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 109: Latex Liyaqat

Defining a Theorem

In the command newtheoremtheoremTheorem the firstargument is the name of the environment and the second argumentis the name which is used when LATEX typesetsThere are three available styles for your proclamations (from mostemphatic to least)plaindefinitionremarkPrecede the definition of your proclamation withtheoremstylestyle to apply that style to that proclamationNote You will now need the amsthm package loaded in yourpreamble

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 110: Latex Liyaqat

First Theorem Example

theoremstyleplainnewtheoremtheoremTheoremnewtheoremcorollaryCorollarytheoremstyledefinitionnewtheoremdefinitionDefinitionnewtheoremnoteNotetheoremstyleremarknewtheoremnotationNotationStarred versions produce no numberOpen the third example file (tex) build and view

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 111: Latex Liyaqat

Numbering Theorems Consecutively

In that last example file all of the numbered proclamations werenumbered with a 1 Some people (including me) donrsquot like this toomuch so they use consecutive numberingsnewtheoremtheoremTheoremnewtheoremlemma[theorem]LemmaThe optional argument tells LATEX to number theorems and lemmasconsecutivelyNote this optional argument must refer to something that hasalready been defined

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 112: Latex Liyaqat

Numbering Theorems Within a Section

The newtheorem command has a second optional argumentwhich can cause proclamations to be numbered within a sectionFor examplenewtheorempropositionProposition[section]causes the propositions in section 1 to be Proposition 11Proposition 12 and so onYou can combine consecutive numbering and numbering withinsections tooOpen the fourth example file (tex) build and view

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 113: Latex Liyaqat

The Proof Environment

LATEX also provides a proof environment used for proofs Itarranges things slightly differently than a theorem or definition andit ends with the symbolAdd these lines to the end of the last example documentbeginproofThis seems fairly obviousendproofBuild it and view

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 114: Latex Liyaqat

A Note for Proclamations and Lists

If a proclamation of yours begins with a list the spacing doesnrsquot lookquite right if you just launch into it Use hfill directly afteropening the environmentbeginlemma hfillbeginenumerateitem This is the first factitem This is the second factendenumerateendlemmaAdd this to the end of the last example file build and view Thendelete the and do it again to see the difference

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 115: Latex Liyaqat

Cross-referencing (Labels)

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 116: Latex Liyaqat

An Example

Open the sixth example file (tex) build it (twice) and viewA few comments1 Note that eqref returns the equation number as it appears inthe equation2 Note the use of the tie (tilde) in citing the TheoremTo see the power of LATEX add two lines to your tex file directlybefore begintheoremsetcountertheorem3setcounterequation20After numbers change in your article you donrsquot have to change thereferences

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 117: Latex Liyaqat

Page References

The command pagerefname returns the page number wherelabelname is locatedAdd these two lines to the end of the last example filenewpageGo back to page~pagerefEareaBuild (twice) and view

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 118: Latex Liyaqat

Equation Tags

You can assign a ldquotagrdquo to an equation by tagtext so that textwill appear on the line with the equation instead of the equationnumberbeginequationA = pi r^2 tagarea of a circleendequationThe text is typeset as text so if you wish to use a math symbolyoursquoll have to put it in math modebeginequationA = pi r^2 tag$star$endequation

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 119: Latex Liyaqat

Suppressing Equation Numbers

There are two ways to suppress equation numbers inside ofdisplaymath environments that have numbers1 If you want to suppress all numbers in that environment usethe starred version of the environment Use align instead ofalign2 If yoursquod just like to suppress one use the notag commandbeginalign2 times 3 amp= 6 3 times 4 amp= 12 notagendalign

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 120: Latex Liyaqat

Customizing enumerate

Since enumerate gives a numbered list there are counters that goalong with each of the four levels of possible nesting1 First level

(a) Second leveli Third level

A Fourth level

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 121: Latex Liyaqat

Including Graphics in a Document

Types of GraphicsVector Graphics drawn using geometrical objects like linespolygons circles image information stored mathematicallyeasy to scale and rotate without loss of quality generallydevice-independentBitmaps without lossy compression image information storedas pixels scaling and rotating leads to slight loss in qualityprinting to the wrong device can give problemsBitmaps with lossy compression some detail is lost incompression but usually the human eye cannot detect itworks well for gradual color changes like in pictures not goodfor graphics with sharp borders most common is JPEG

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 122: Latex Liyaqat

What Graphics Format Shall I Use

For drawings use vector graphics You get maximum freedom forimage manipulation once you include into your document Use EPSusuallyIf you must use bitmaps use PNGFor photographs JPEG is usually best

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 123: Latex Liyaqat

Choosing Your Profile

As usual we will produce pdf files There are two options1 Profile LaTeX =gt PDF2 Profile LaTeX =gt PS =gt PDFHow do you choose

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 124: Latex Liyaqat

Using the graphicx package

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 125: Latex Liyaqat

Manipulating Images

scaling With the option scale=05 your picture will be scaleddown to half its normal size With the option scale=125 itwill appear as 125 of its normal sizerotation With the option angle=45 your picture will appearrotated counter-clockwise by 45 degrees With the optionangle=-30 your picture will appear rotated clockwise by 30degreesheight and width With the option height=1in your picture willbe scaled proportionally so that it has a height of 1-inch Withthe option width=2in your picture will have a width of2-inches If you use both your proportions might get messedup To prevent this use the keepaspectratio option LATEXwill scale proportionally so that the the dimensions you specifyare maximum

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 126: Latex Liyaqat

Wrapping Text Around a Picture

The wrapfig package provides a way to wrap text around apicturefigure Yoursquoll need to use the wrapfigure environmentwhere you want the top of the figure to bemdasheven if it is in the middleof the paragraphHerersquos the syntax of the commandbeginwrapfigure[lineheight]alignmentwidthfigure hereendwrapfigureOpen the fourth example file (tex) and make sure thatobamajpg is in the same folderBuild and view

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 127: Latex Liyaqat

Floats

Tables and figures cannot be broken across pages For this reasonthey are called floats in LATEX This is because sometimes LATEXldquofloatsrdquo them to the top or bottom of the current page (or even thenext one) when it is calculating the best spot for themTables go inside the table environmentFigures go inside the figure environment

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 128: Latex Liyaqat

Tables

The setupbegintablebegincenterbegintabularendtabularcaptiontext labelTanameendcenterendtableThe caption command is optional as is the label commandHowever if you have both of them label must come betweencaption and endtableCentering the table isnrsquot mandatory but it does make things looknicer I think

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 129: Latex Liyaqat

Figures

The figure environment is virtually identical to the tableenvironmentbeginfigurebegincenterincludegraphicscaptiontext labelFinameendcenterendfigure

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 130: Latex Liyaqat

Controlling the Floats

The table and figure environments have an optional argumentwhich can influence where LATEX places the table or figure Theoptional argument consists of one to four of the following lettersbull b the bottom of the pagebull h here (where the environment is typed)bull t the top of the pagebull p a separate pageSo begintable[hb] requests that the table be placed here orat the bottom of the page The order of the letters doesnrsquot matter ifh is present it takes precedence The default is [tbp]

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 131: Latex Liyaqat

What is BibTeX

BibTeX is an application that runs alongside LATEX to assist the userin compiling bibliographies It especially shines if your bibliographyis longWhat do you need to use BibTeX A bibliographic database filemdashthis will have a bib extensionThis is where the bibliographic entries are located You need tocreate this file A bibliographic style filemdashthis will have a bst extension Youdo not need to create this it will be provided

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 132: Latex Liyaqat

Style Options

There are six options (for now) for bst files with which to concernyourself (Most journals provide their own bst files to use)

plainbst sorts according to name of authorlabels are numbers

alphabst alphanumeric labelssorting by labels

unsrtbst references sorted by order of appearancenumeric labels

abbrvbst much like plain abbreviates firstnames of authors journals months

amsplainbst AMS version of plainamsalphabst AMS version of alpha

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 133: Latex Liyaqat

The Basics

Suppose that you already have a bib file (Thatrsquos the hardestpart) Letrsquos say that itrsquos called worksbib If you want to use theamsplain style these two lines go at the end of your documentenvironmentbibliographystyleamsplainbibliographyworksEach item in the bibliography database has a key just like withnormal bibliographies We use the citekey command in thesame way BibTeX will automatically place all cited works into yourlist of ReferencesYou can also place non-cited works into your References by usingthe nocitekey command in the document

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 134: Latex Liyaqat

Typing Entries

BibTeX takes care of all of the formatting so you donrsquot need toworry about the punctuation that will be in the bibliography itselfGeneral syntaxfield = Note that the braces and the comma are requiredMany bibliography styles convert titles to lowercase for all entrytypes If you want a letter to appear in uppercase put the word (orthe whole title) in bracesauthor=McMahonorauthor=McMahon

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 135: Latex Liyaqat

A Book

For the BOOK entry typerequired author (or editor) title publisheryearoptional edition series volume number addresslanguageBOOKdiazauthor = Junot Drsquoiaztitle = The Brief Wonderous Life of Oscar Waopublisher = Riverhead Booksaddress = New Yorkyear = 2008

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 136: Latex Liyaqat

An Article

For the ARTICLE entry typerequired author title journal year pagesoptional volume number language notearticlesharkeytitle=The Ethical Frontiers of Roboticsauthor=Sharkey Njournal=Sciencevolume=322number=5909pages=1800-1801year=2008

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 137: Latex Liyaqat

A Website

There isnrsquot any website entry option for BibTeX So we have tomake use of another entry typemdashwersquoll use misc In order to dothis make sure that usepackageurl is in your preamblemiscMLKtitle=Martin Luther King Jrhowpublished=urlhttpenwikipediaorgwikiMartin_Luther_King_Jrnote=accessed on 01162012

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 138: Latex Liyaqat

Completing This Example

Add these three entries to the math233bib file that we workedwith earlier Add this line before bibliographystyle within theprevious example filenocitediazsharkeyMLKNow go back through the four step process to build a PDF inTeXnicCenter When you view it make sure these entries show upproperly in the bibliography

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 139: Latex Liyaqat

Concluding Comments

A few notes1 The command nocite within your document will includeevery entry from your bib file in your bibliography2 One of the great advantages of BibTeX is the re-use ofreferences You can simply re-use your bib file3 BibTeX has a learning curve Be patient and work at it4 I have posted some documentation help on our web page Lookunder Miscellaneous Resources

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 140: Latex Liyaqat

The biblatex package

The biblatex package uses BibTeX but it changes the way thebibliographic entries and citations are processedOne consequence is that there are a lot more of the widely-usedcitationbibliography styles available for use with biblatex thanpreviously coveredNote This package is relatively new (first written in 2010) so therewill likely be a lot more development on it in the next few years Iforesee biblatex becoming the dominant way to do bibliographiesin LATEX over the next 5ndash10 years and Irsquom hoping this will open thedoor for more in the social sciences and humanities to use LATEX

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 141: Latex Liyaqat

The basics

To start yoursquoll need the following in your preambleusepackagebiblatexAlso in the preamblebibliographyltfilegt(Actually this just needs to be somewhere before where thebibliography itself shows up in your tex file)Then where you want your bibliography to appear you typeprintbibliography

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 142: Latex Liyaqat

The package options

When loading the package in the preamble you have severaloptions that can be employedusepackage[options]biblatexSome of these options include

bull style=name loads bibliography and citation stylebull bibstyle=name loads bibliography style

bull citestyle=name loads citation styleI have posted a list of the bibliography and citation styles that areavailable (I simply made excerpts of the biblatex userrsquos manual)

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 143: Latex Liyaqat

Basic citation commands

Irsquove posted the full list of these but here are the basicsBasic syntax of the commandscommand[prenote][postnote]keyscite standard citation in square bracketsparencite enclose citation in parenthesesfootcite put citation in footnotetextcite to be used in place of subject of sentenceSee posted document for moreOpen the third example file (tex) build and viewMake sure that the example3bib file is in the same folder

  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152
Page 144: Latex Liyaqat
  • Slide 1
  • Slide 2
  • Slide 3
  • Slide 4
  • Slide 5
  • Slide 6
  • Slide 7
  • Slide 8
  • Slide 9
  • Slide 10
  • Slide 11
  • Slide 12
  • Slide 13
  • Slide 14
  • Slide 15
  • Slide 16
  • Slide 17
  • Slide 18
  • Slide 19
  • Slide 20
  • Slide 21
  • Slide 22
  • Slide 23
  • Slide 24
  • Slide 25
  • Slide 26
  • Slide 27
  • Slide 28
  • Slide 29
  • Slide 30
  • Slide 31
  • Slide 32
  • Slide 33
  • Slide 34
  • Slide 35
  • Slide 36
  • Slide 37
  • Slide 38
  • Slide 39
  • Slide 40
  • Slide 41
  • Slide 42
  • Slide 43
  • Slide 44
  • Slide 45
  • Slide 46
  • Slide 47
  • Slide 48
  • Slide 49
  • Slide 50
  • Slide 51
  • Slide 52
  • Slide 53
  • Slide 54
  • Slide 55
  • Slide 56
  • Slide 57
  • Slide 58
  • Slide 59
  • Slide 60
  • Slide 61
  • Slide 62
  • Slide 63
  • Slide 64
  • Slide 65
  • Slide 66
  • Slide 67
  • Slide 68
  • Slide 69
  • Slide 70
  • Slide 71
  • Slide 72
  • Slide 73
  • Slide 74
  • Slide 75
  • Slide 76
  • Slide 77
  • Slide 78
  • Slide 79
  • Slide 80
  • Slide 81
  • Slide 82
  • Slide 83
  • Slide 84
  • Slide 85
  • Slide 86
  • Slide 87
  • Slide 88
  • Slide 89
  • Slide 90
  • Slide 91
  • Slide 92
  • Slide 93
  • Slide 94
  • Slide 95
  • Slide 96
  • Slide 97
  • Slide 98
  • Slide 99
  • Slide 100
  • Slide 101
  • Slide 102
  • Slide 103
  • Slide 104
  • Slide 105
  • Slide 106
  • Slide 107
  • Slide 108
  • Slide 109
  • Slide 110
  • Slide 111
  • Slide 112
  • Slide 113
  • Slide 114
  • Slide 115
  • Slide 116
  • Slide 117
  • Slide 118
  • Slide 119
  • Slide 120
  • Slide 121
  • Slide 122
  • Slide 123
  • Slide 124
  • Slide 125
  • Slide 126
  • Slide 127
  • Slide 128
  • Slide 129
  • Slide 130
  • Slide 131
  • Slide 132
  • Slide 133
  • Slide 134
  • Slide 135
  • Slide 136
  • Slide 137
  • Slide 138
  • Slide 139
  • Slide 140
  • Slide 141
  • Slide 142
  • Slide 143
  • Slide 144
  • Slide 145
  • Slide 146
  • Slide 147
  • Slide 148
  • Slide 149
  • Slide 150
  • Slide 151
  • Slide 152