latex’s way of thinking: in boxesrajendrakachhwaha.co.in/content/asgn/latex - basic.pdflatex’s...

42
L A T E X’s Way of Thinking: in Boxes I L A T E X “thinks” in boxes. This is fundamental . I It does not typeset letters, it prints boxes ! I L A T E X encloses everything in imaginary rectangles. 1. letters 2. figures 3. tables 4. pages 5. even lines 6 / 44

Upload: others

Post on 13-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

LATEX’s Way of Thinking: in Boxes

I LATEX “thinks” in boxes. This is fundamental.

I It does not typeset letters, it prints boxes!I LATEX encloses everything in imaginary rectangles.

1. letters2. figures3. tables4. pages5. even lines

6 / 44

Page 2: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

LATEX’s Way of Thinking: in Boxes

Figure 2: Each box has three dimensions!

ghost7 / 44

Page 3: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

LATEX’s Way of Thinking: in Boxes

the ghostbusters

Sed commodo posuere pede.Mauris ut est. Ut quis pu-rus. Sed ac odio. Sed vehic-ula hendrerit sem. Duis nonodio. Morbi ut dui. Sed ac-cumsan risus eget odio. In hachabitasse platea dictumst. Pel-lentesque non elit. Fusce sedjusto eu urna porta tincidunt.Mauris felis odio, sollicitudinsed, volutpat a, ornare ac, erat.Morbi quis dolor. Donec pel-lentesque, erat ac sagittis sem-per, nunc dui lobortis purus,quis congue purus metus ul-tricies tellus. Proin et quam.Class aptent taciti sociosqu adlitora torquent per conubia nos-tra, per inceptos hymenaeos.Praesent sapien turpis, fermen-tum vel, eleifend faucibus, ve-hicula eu, lacus.∫ (

∂2f∂x2

)2

dx

cosϕ − sinϕsinϕ cosϕ0 0

1

1This is borrowed from an article by Ivan Ramos Pagnossin:http://stoa.usp.br/irpagnossin/files/-1/8394/boxes_en.pdf

8 / 44

Page 4: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

LATEX’s Way of Working: in Two StagesExtension Usagetex source file(s)sty LATEX packages or style filesbst bibliography style packageslog temporary file for (error) loggingaux temporary file for reference handling, i.e. \label{} . . . \ref{}toc temporary file for the Table Of Contents produced by \tableofcontentslof, lot List Of Figures \listoffigures, List Of Tables \listoftablesbib bibliography data base, handled by BibTeXblg temporary file for bibliography references, similar to aux

produced by \cite, \citet , \citep ,2 etc.

dvi output file, device independent, printable text(open with GhostView on Windows-box)3

ps, pdf Post-Script, Portable Document Format files containing printable text. . . and many more

Files with red colored extensions, e.g. tex, bib, should never be removed. Everythingelse is reproducible.

2Commands in grey boxes require \usepackage{natbib}3See http://www.fileinfo.com/extension/dvi for other platforms

9 / 44

Page 5: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

Create or edit a tex file in youreditor.

\documentclass{article}\begin{document}Hi there!\end{document}

1st compilation with pdfLATEX orLATEX. Produces temporary files.

toc logaux loflot ...

2nd compilation withpdfLATEX. Producesfinal Portable Device

Format (PDF).

2nd compilation withLATEX. Produces

Device IndependentFormat (DVI).

Convert DVI to PS(Post-Script format).

LATEX requires two passes over theinput:

1. one to find the information

2. second to put it into the text

Table of contents, labels, list of fig-ures, etc all require two passes.

I A plain text with nocross-reference would be finewith just a single pass.

I The cross-referencinginformation is stored intemporary files to avoiddouble compilation eachtime.

10 / 44

Page 6: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

Installation

I On Windows you can install fromhttp://miktex.org/.

I On Debian Based Linux distributions you goapt-get install texlive-full

Never install MiKTeX in:C:\Program Files\whatsoever

This could be painful

11 / 44

Page 7: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

Installation

I On Windows you can install fromhttp://miktex.org/.

I On Debian Based Linux distributions you goapt-get install texlive-full

Never install MiKTeX in:C:\Program Files\whatsoever

This could be painful

11 / 44

Page 8: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

TeXnic Center or WinEdt is not LATEX. . .

.. it is your editor.

During this course we will need merely a single button:

I in WinEdt

I in TeXnic Center

12 / 44

Page 9: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

First Steps

13 / 44

Page 10: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

The Absolute Minimal LATEX Document

\documentclass{article}

\begin{document}

Hello there!

\end{document}

14 / 44

Page 11: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

A Standard LATEX Document

\documentclass{article} <–-|

\usepackage{color} |

\usepackage{graphicx} | preamble

... |

\begin{document} <–-|

<–-|

Hello there! | text of your document

<–-|

\end{document}

everything below is ignored

15 / 44

Page 12: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

A Standard LATEX Document

\documentclass{article} <–-|

\usepackage{color} |

\usepackage{graphicx} | preamble

... |

\begin{document} <–-|

<–-|

Hello there! | text of your document

<–-|

\end{document}

everything below is ignored

15 / 44

Page 13: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

\documentclass{class}

Document classes:

\documentclass{article}\documentclass{report}\documentclass{book}\documentclass{letter}\documentclass{beamer} % The course-slides for example\documentclass{slides}

16 / 44

Page 14: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

\documentclass[options]{class}

It can be used with or without additional options:

\documentclass[10pt]{article} % 10pt|11pt|12pt\documentclass[final]{article} % draft|final\documentclass[a4paper]{article} % a4paper|a5paper|letterpaper|...\documentclass[twoside]{book} % oneside|twoside\documentclass[openright]{book} % openright|openany\documentclass[notitlepage]{article} % notitlepalge|titlepage\documentclass[onecolumn]{article} % onecolumn|twocolumn\documentclass[a4paper,oneside,12pt]{article} % combined with comma

17 / 44

Page 15: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

The Ten Special Characters

# $ % & _ { } ~ ^ \

If you want to use them in your documents, e.g. type $5, you needto produce them through commands.

I We saw the comment command % in use already.

I Seven of them, those which are likely to appear in real text,are very easily reproducible:

# $ % & _ { } \# \$ \% \& \_ \{ \}

I The other three special symbols require longer commands:\ ^ ~ \textbackslash \symbol{94} \symbol{126}

They usually appear in simulated keyboard input.

18 / 44

Page 16: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

Sentences and Paragraphs

We start with a mid-size logical structure: sentences andparagraphs.

Dolphins are often regarded as one ofEarth’s most intelligent animals, thoughit is hard to say just how intelligent.

Compared to many other species how-ever, dolphin behavior has been studiedextensively, both in captivity and in thewild.

1 Dolphins are often regarded as one2 of Earth ’s most intelligent animals ,3 though it is hard to say just how4 intelligent.567 Compared to many other species however ,8 dolphin behavior has been studied9 extensively , both in captivity and in

10 the wild.

I LATEX ignores the way the input is formated. Note the white spaces in theinput which correspond to normal inter-word spaces. LATEX pays attentionon the logical structure: two paragraphs in this case.

I Different paragraphs are separated by a blank line. This is the singlevisual input which corresponds to the WYSIWYG design. More blanklines do not produce bigger space!

19 / 44

Page 17: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

Sentences and ParagraphsDolphins are often regarded as one of

Earth’s most intelligent animals, thoughit is hard to say just how intelligent.

Compared to many other species how-ever, dolphin behavior has been studiedextensively, both in captivity and in thewild.1

1Talking about footnotes.

1 Dolphins are often regarded as one2 of Earth ’s most intelligent animals ,3 though it is hard to say just how4 intelligent .\\[0.2 cm]56 Compared to many other species however ,7 dolphin behavior has been studied8 extensively , both in captivity and in9 the wild.\ footnote{Talking about

10 footnotes .}1112 % This is a comment.

I If you want to stretch the between-paragraph space you can do it globally (wecover this later) or locally, e.g. you have to tell LATEX that you need more spacethere.

I \\ is almost equivalent to \newline, i.e. \newline[2cm] would ignore the[2cm] option.

I We produced the footnote via the \footnote command.

I Note the use of one of our special symbols %. It denotes the beginning of acomment. Use it generously!

20 / 44

Page 18: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

The Title Page

A LATEX CourseArticle

T. J. Somebody Will White, Jr.Bill Black

October 6, 2018

1 \title{A \LaTeX\ Course Article}2 \author{T. J. Somebody \and3 Will White , Jr. \and Bill Black}4 \date{October 6, 2018}5

6 \maketitle

I The actual title page is generated by \maketitle. The commands \title,\author and \date can be, and usually are, specified in the preamble.

I \maketitle comes after the \begin{document}.I The \date is optional, current date is used if omitted. \title and \author

must be present (if you intend to use \maketitle of course).I \today provides the actual date, i.e. \date{\today}.I Note that we write \and to separate several authors.I The command \LaTeX produces the LATEX logo.

21 / 44

Page 19: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

Sectioning (Gliederungsbefehle)The paragraphs are organized into bigger logical structures. Theirdistinguishing feature is the hierarchical structure.

I Section units are declared via sectioning commands(Gliederungsbefehle). The unit’s title is their argument.\section{Section’s Title}

I There is a second title as an optional argument declared inbrackets.\section[optional name]{Section’s Title}

I Another sectioning commands are:\chapter

\section

\subsection

\subsubsection

\part

\paragraph

\subparagraph

22 / 44

Page 20: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

Sectioning Example

1 Earth’s Most Intelligent Ani-

mals

Dolphins are often regarded as one of Earth’s mostintelligent animals, though it is hard to say just howintelligent.

1.1 Origin of The Name

The name is originally from Ancient Greek (delphs;”dolphin”), which was related to the Greek (delphys;”womb”). The animal’s name can therefore be inter-preted as meaning ”a ’fish’ with a womb”.[1] The namewas transmitted via the Latin delphinus, Middle Latindolfinus and the Old French daulphin, which reintro-duced the ph into the word.

2 Other animals

Compared to many other species however, dolphin be-havior has been studied extensively, both in captivityand in the wild.

1

\section{Earth’s MostIntelligent Animals}Dolphins are often regarded as one ofEarth’s most intelligent animals,though it is hard to say justhow intelligent.

\subsection{Origin of The Name}The name is originally from AncientGreek...into the word.

\section{Other animals}Compared to many other species however,dolphin behavior has beenstudied extensively, both in captivityand in the wild.

23 / 44

Page 21: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

Table of Contents

I A \tableofcontents command produces a table of contents.

I If you use the optional argument\section[optional name]{Section’s Title}

exactly this optional name is shown in the table of contents.This is also true for the headers produced by the packagefancyhdr. This is useful for long section names.

I \section*{Section’s Title}

suppresses the enumeration of the given section and itsinclusion in the table of contents.

I If you use \usepackage[ngerman]{babel} it will produceInhaltsverzeichnis instead of Contents.

24 / 44

Page 22: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

Sectioning Example - Table of Contents

Contents

1 Earth Intelligence 11.1 Origin . . . . . . . . . . . . . . . . . . . . . . . . 1

2 Others 1

1 Earth’s Most Intelligent Ani-

mals

Dolphins are often regarded as one of Earth’s most intelligentanimals, though it is hard to say just how intelligent.

1.1 Origin of The Name

The name is originally from Ancient Greek (delphs; ”dolphin”),which was related to the Greek (delphys; ”womb”). The an-imal’s name can therefore be interpreted as meaning ”a ’fish’with a womb”.[1] The name was transmitted via the Latin del-phinus, Middle Latin dolfinus and the Old French daulphin,which reintroduced the ph into the word.

2 Other animals

Compared to many other species however, dolphin behavior hasbeen studied extensively, both in captivity and in the wild.

1

\tableofcontents\section[Earth Intelligence]{Earth’s MostIntelligent Animals}Dolphins are often regarded as one ofEarth’s most intelligent animals,though it is hard to say justhow intelligent.

\subsection[Origin]{Origin of The Name}The name is originally from AncientGreek...into the word.

\section[Others]{Other animals}Compared to many other species however,dolphin behavior has beenstudied extensively, both in captivityand in the wild.

25 / 44

Page 23: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

LATEX is not a spectator sport.

Hands on the keyboards for the first exercise.

26 / 44

Page 24: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

Exercise 1

Please find the file 01basics.pdf on the homepage. Try to reproduce the document.

A guidance on the assignment sheet:

1. Begin your document with:\documentclass[a4paper,oneside,12pt]{article}

2. Use\usepackage[ngerman]{babel} – for the German language\usepackage[latin1]{inputenc} – for proper encodingSection 1.1 in your exercise sheet will give you hints about the German Umlauts.

3. All author’s details are placed as argument of the \author command. Theseparate lines are produced as usual by \\.

4. Use the \url command from the \url package to show web-links.

5. You can define a word division (Silbertrennung) at a specified place by using \-.

6. The \verb command allows you to insert short selections of literal text into aLATEX document. See here for details on how to use it:http://www.weinelt.de/latex/verb.html

27 / 44

Page 25: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

Change Page Format with geometrypaper

total body

height

width

paperwidth

paperheight

top

bottom

left(inner)

right(outer)

?

?

6

6

-� -�

total body

head headheightheadsep

textheight

textwidth

footskip

body

foot

Figure 1: Dimension names used in the geometry package. width=textwidth andheight=textheight by default. left, right, top and bottom are margins. If marginson verso pages are swapped by twoside option, margins specified by left and right

options are used for the inside and outside margins respectively. inner and outer arealiases of left and right respectively.

\usepackage[total={6.5in,8.75in},top=1.2in, left=0.9in, includefoot]{geometry}.

Setting a text area on the paper in document preparation system has some analogy to placing awindow on the background in the window system. The name ‘geometry’ comes from the -geometryoption used for specifying a size and location of a window in X Window System.

4 Page geometry

4.1 Layout dimensions

To realize a straightforward setting for page layout, the following page structure is introduced: A papercontains a total body (printable area) and margins. The total body consists of a body (text area) withoptional a header, a footer and marginal notes (marginpar). There are four margins: the left, right,top and bottom margins. For twosided documents, horizontal margins should be called the inner andouter margins.

paper : total body and marginstotal body : body (text area) (optional head, foot and marginpar)

margins : left(inner), right(outer), top and bottom

Each margin is measured from the corresponding edge of a paper. For example, left margin (innermargin) means a horizontal distance between the left (inner) edge of the paper and that of the totalbody. Therefore the left and top margins defined in geometry are different from the native dimensions\leftmargin and \topmargin. The size of a body (text area) can be modified by \textwidth and\textheight.

The layout parts and the corresponding dimension names used in this package are showed schemat-ically in Figure 1. The dimensions for paper, total body and margins have the following relations.

paperwidth = left + width + right (1)paperheight = top + height + bottom (2)

The dimensions of the total body, width and height, are defined as follows:

width := textwidth (+marginparsep + marginparwidth) (3)height := textheight (+headheight + headsep + footskip) (4)

In Equation (3), width:=textwidth by default, but marginparsep and marginparwidth are includedin width if includemp option is set true. In Equation (4), height:=textheight by default. If

4

\usepackage[text={6.5in,8.75in}, top=1.2in, left=0.9in]{geometry}\usepackage[text={16cm,22cm}, centering]{geometry}

See the manual of geometry for an excellent overview.28 / 44

Page 26: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

Spacing

%% set the inter-line spacing for the whole document

\usepackage{setspace}

\onehalfspacing % \doublespacing, \setstretch{1.1}

%% set the inter-line spacing for a single paragraph

\begin{doublespace}

This paragraph has \\ double \\ line spacing.

\end{doublespace}

\setlength{\parindent}{0pt} % no indentation

29 / 44

Page 27: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

SpacesLATEX is very sensitive when it comes to space.

fixed spaces\hspace{len} \hspace*{len} Horizontal space, len can be 2cm, 2in, 2pt, etc.

The space produced by \hspace is removed ata line brake, that produced by \hspace* is not.

\vspace{len} \vspace*{len} Adds a vertical space of height lenThe space produced by \vspace is removed ata page brake, that produced by \vspace* is not.

\bigskip \medskip \smallskip Vertical space-producing commands.\, \␣ \quad \qquad Horizontal space-producing commands.

elastic spaces\hfill \hspace{\fill} Infinitely stretchable horizontal space. It stretches as

much as it can (in the line), useful for text centering.\vfill \vspace{\fill} Infinitely stretchable vertical space. It stretches as

much as it can (in the page), useful for text centering.\dotfill Just like \hfill except it produces dots instead of

spaces.\hrulefill Just like \hfill except it produces a horizontal line

instead of spaces.30 / 44

Page 28: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

Space ExamplesHere is a 5 mm space.Here is a 5 mm space.Here is a 5 mm space.Here is a 5 mm space.Below is 1 cm vertical space.

Here is below.Where is the 5 mm space?

Where is the 5 mm space?

Here\hspace{5mm}is a 5 mm space.Here \hspace{5mm}is a 5 mm space.Here \hspace{5mm} is a 5 mm space.Here \hspace{5mm} is a 5 mm space.Below \vspace{1cm} is 1 cm vertical space.Here is below.\hspace{5mm} Where is the 5 mm space?\hspace*{5mm} Where is the 5 mm space?

I Recall: The space produced by \hspace is removed at a linebrake, i.e. at the beginning or end of each line of output text!The space produced by \hspace* is never removed.

I For \vspace holds the same logic as for \hspace except thatits concerns pages instead.

31 / 44

Page 29: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

Space ExamplesHere is a 5 mm space.Here is a 5 mm space.Here is a 5 mm space.Here is a 5 mm space.Below is 1 cm vertical space.

Here is below.Where is the 5 mm space?

Where is the 5 mm space?

Here\hspace{5mm}is a 5 mm space.Here \hspace{5mm}is a 5 mm space.Here \hspace{5mm} is a 5 mm space.Here \hspace{5mm} is a 5 mm space.Below \vspace{1cm} is 1 cm vertical space.Here is below.\hspace{5mm} Where is the 5 mm space?\hspace*{5mm} Where is the 5 mm space?

I Recall: The space produced by \hspace is removed at a linebrake, i.e. at the beginning or end of each line of output text!The space produced by \hspace* is never removed.

I For \vspace holds the same logic as for \hspace except thatits concerns pages instead.

31 / 44

Page 30: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

Elastic Space Examples

This is a stretched space.Two stretched spaces.Three stretched spaces?Three stretched spaces?Three stretched spaces?

A. . . . . . . .dotted space. . . . . . . . .A . . . . . . . . . . . . . . . . dotted space.An underlined space.

This is a \hfill stretched space.Two \hfill stretched \hfill spaces.Three \hfill stretched \hfill spaces?\hfillThree \hfill stretched \hfill spaces?\hspace*{\fill}Three \hfill stretched \hfill spaces?\hfill\\vfillA \dotfill dotted space.\dotfillA \dotfill dotted space.An \hrulefill underline space.

I Multiple \hfill commands produce equal spaces within a line.

I \hfill does disappear at the the beginning or at the the endof a line, \dotfill and \hrulefill do not.

I Why did \hfill not disappear at the end of the fifth line?

32 / 44

Page 31: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

Elastic Space Examples

This is a stretched space.Two stretched spaces.Three stretched spaces?Three stretched spaces?Three stretched spaces? ␣

A. . . . . . . .dotted space. . . . . . . . .A . . . . . . . . . . . . . . . . dotted space.An underlined space.

This is a \hfill stretched space.Two \hfill stretched \hfill spaces.Three \hfill stretched \hfill spaces?\hfillThree \hfill stretched \hfill spaces?\hspace*{\fill}Three \hfill stretched \hfill spaces?\hfill\\vfillA \dotfill dotted space.\dotfillA \dotfill dotted space.An \hrulefill underline space.

I Multiple \hfill commands produce equal spaces within a line.

I \hfill does disappear at the the beginning or at the the endof a line, \dotfill and \hrulefill do not.

I Why did \hfill not disappear at the end of the fifth line?

32 / 44

Page 32: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

Quotations

An environment consists of\begin{environment}

. . .\end{environment}

where everything in between is enclosed in the environment. Wetreat environments more extensively later on.Two different environments display quotations in LATEX.

quote is used for short quotations consisting of few words orsentences.

quotation is used for longer quotations of more than oneparagraph.

33 / 44

Page 33: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

Quotation Examples

Someone once said:

There are only 10 types ofpeople in the world: Thosewho understand binary, andthose who don’t.

and he was right.

And here is a longer quotation:

Let epsilon be less thanzero...

Tell it at a party, andthose who laugh must bemathematicians.

Someone once said:\begin{quote}

There are only $10$ types of peoplein the world:Those who understand binary, andthose who don’t.

\end{quote}and he was right.

And here is a longer quotation:\begin{quotation}

Let epsilon be less than zero...

Tell it at a party, and thosewho laugh must be mathematicians.

\end{quotation}

34 / 44

Page 34: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

Emphasizing Text (I Part)

Italicized text.Underlined text.Typewriter text.Boldface text.Slanted shape text.Roman text.Small caps text.

\textit{Italicized} text.\underline{Underlined} text.\texttt{Typewriter} text.\textbf{Boldface} text.\textsl{Slanted shape} text.\textrm{Roman} text.\textsc{Small caps text}.

I \textit is the command, Italicized is its argument.

I Most command have either no arguments, e.g. \today,\hfill, or a single argument, like \textit. However, thereare a few with multiple arguments (covered later in thecourse), each of which should be enclosed in braces.

I All of these commands have equivalent declarations,e.g. \textit = \itshape which we cover in the next slide.

35 / 44

Page 35: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

Declarations (Deklarationen, Erklärungen)

William Edwards Deming oncesaid

In God we trust, allothers bring data.

and he was right.

William Edwards Deming once said\\\begin{quote}In God we trust, \bfseries allothers bring data.

\end{quote}and he was right.

The shaded regions are the scope of the \bfseries declaration.This is a { \bfseries nice example } of a declaration.

Text1 { \begin{quote} \bfseries { text2 } text3 \end{quote} text4 } text5

I Declarations affect the way LATEX prints the text that follows it!

I The scope of a declaration is ended by an \end or a right brace } whosematching \begin or left brace { precedes the declaration!

I The \{ and \} commands do not count for the purpose of bracematching.

36 / 44

Page 36: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

Emphasizing Text (II Part)

Most text-producing commands have corresponding declarations:

Command Declaration

\textit \itshape

\texttt \ttfamily

\textbf \bfseries

\textsl \slshape

\textrm \rmfamily

\textsc \scshape

I You should use the commands rather than the declarations forsmall pieces of text because they produce better spacing.

37 / 44

Page 37: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

Colors

To use colors you need to include in the preamble

I \usepackage{color} for normal colors or

I \usepackage{xcolor} for mixed (transparent) colors.

This text is in blue.This text is in red.This text is in green.This text is in magenta.

This text is in blue.This text is in red.This text is in green.This text is in magenta.

% declarationsThis text {\color{blue}is in blue}.This text {\color{red}is in red}.This text {\color{green}is in green}.This text {\color{magenta}is in magenta}.

% normal commandsThis text \textcolor{blue}{is in blue}.This text \textcolor{red}{is in red}.This text \textcolor{green}{is in green}.This text \textcolor{magenta}{is in magenta}.

38 / 44

Page 38: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

Mixed Colors with xcolor

This text is in 40% blue.This color is a mixture of 60% red and 40% yellow.This color is the supplement of 60% red and 40% yellow.This color is a mixture of 50% red!60!yellow and 50% blue.This color is 100% blue.

This text {\color{blue!40}is in 40\% blue}.This color \textcolor{red!60!yellow}{is a mixture of 60\% red

and 40\% yellow}.This color \textcolor{-red!60!yellow}{is the supplement of 60\% red

and 40\% yellow.}This color \textcolor{red!60!yellow!50!blue}{is a mixture

of 50\% \uline{red!60!yellow} and 50\% \uline{blue}.}This color \textcolor{red!60!yellow!0!blue}{is 100\% blue.}

39 / 44

Page 39: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

Type Size

The precise size of type produced by these declarations dependsupon the default type size, i.e. 10pt,11pt,12pt

Text Declaration Text Declaration

tiny \tiny large \large

scriptsize \scriptsize Large \Large

footnotesize \footnotesize LARGE \LARGE

small \small huge \huge

normalsize \normalsize Huge \Huge

I NB: If those ten declarations are too restrictive for your needs,you can define your own font-size.

My tiny text.\def\mytiny{\fontsize{5pt}{4pt}\selectfont}{\mytiny My tiny text.}

40 / 44

Page 40: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

Environments (Umgebungen)An environment has the form

\begin{name} . . . \end{name}

I To every declaration corresponds an environment whose nameis the same as the declaration’s name without the \. Forinstance, \bfseries is equivalent to\begin{bfseries} . . . \end{bfseries}

I By now we have met two environments: document and quote.I itemize is another popular environment (next slide).I Always match \begin{itemize} with \end{itemize}

otherwise the error messages looks like! LaTeX Error: \begin{itemize} on input line ... ended by \end{imetize}.

or! LaTeX Error: Environment itemiz undefined.

Note that the two errors represent different types of mistakes!41 / 44

Page 41: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

Environments Can Be Nested\begin{itemize}\item First Item.\item Second Item.

\end{itemize}

I First Item.

I Second Item.

I First Item.

I Second Item.

1. Number One.2. Number Two.3. Number Three.

♠ Spades♥ Hearts♦ Diamonds♣ Clubs

I Last Item.

\begin{itemize}\item First Item.\item Second Item.

\begin{enumerate}\item Number One.\item Number Two.\item Number Three.

\begin{itemize}\item[$\spadesuit$] Spades\item[$\heartsuit$] Hearts\item[$\diamondsuit$] Diamonds\item[$\clubsuit$] Clubs\end{itemize}

\end{enumerate}\item Last Item.\end{itemize}

42 / 44

Page 42: LATEX’s Way of Thinking: in Boxesrajendrakachhwaha.co.in/content/asgn/Latex - Basic.pdfLATEX’s Way of Thinking: in Boxes the ghostbusters Sedcommodoposuerepede. Mauris ut est

References

Lamport, L. (1994). LATEX User’s Guide & Reference Manual,second edn, Addison-Wesley Publishing Company, Inc.

44 / 44