author | Puneeth Chaganti <punchagan@fossee.in> |
Sun, 06 Feb 2011 17:57:03 +0530 | |
changeset 157 | 3174d4803cd5 |
parent 104 | 828c65311bdf |
permissions | -rw-r--r-- |
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
1 |
LaTeX |
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
2 |
===== |
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
3 |
|
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
4 |
Introduction |
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
5 |
------------ |
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
6 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
7 |
LaTeX is a typesetting program that produces excellently typeset documents. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
8 |
Typesetting is placing text onto a page with all the style formatting |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
9 |
defined, so that content looks as intended. It is extensively used for |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
10 |
producing high quality scientific and mathematical documents. It may also be |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
11 |
used for producing other kinds of documents, ranging from simple one page |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
12 |
articles to complete books. LaTeX is based on the TeX typesetting language. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
13 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
14 |
LaTeX is pronounced either as "Lah-tech" or "Lay-tech". |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
15 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
16 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
17 |
Why LaTeX? |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
18 |
~~~~~~~~~~ |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
19 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
20 |
A few reasons for using LaTeX - |
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
21 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
22 |
* It produces documents with excellent visual quality. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
23 |
* It does the typesetting for you, leaving you - the author - to focus on |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
24 |
writing the content. You will appreciate this, as you learn more. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
25 |
* It makes writing math just as easy as writing simple text. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
26 |
* It's renowned for it's stability and a virtually bug free code base. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
27 |
* It is light on your resources as compared to most of the word processors |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
28 |
available today. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
29 |
* It uses plain text files as input and can give output in a variety of |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
30 |
formats including PDFs and html making it platform independent. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
31 |
* It is free software (free as in freedom) and gratis too. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
32 |
* It is widely used and has a large user community. |
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
33 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
34 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
35 |
Course Outline |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
36 |
~~~~~~~~~~~~~~ |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
37 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
38 |
In this course, we will learn enough LaTeX to be a able to produce a simple |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
39 |
document with text, tables, figures, math, references and bibliography. We |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
40 |
will also briefly see how to create presentations using LaTeX, such as the |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
41 |
one use for the slides of this course. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
42 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
43 |
The sample document, ``sample.pdf``, available in the course material, will |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
44 |
serve as a teaching/learning tool to learn LaTeX. During the course, we shall |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
45 |
reproduce this sample document, starting from scratch, in LaTeX |
104 | 46 |
|
47 |
A Look at the Sample Document |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
48 |
+++++++++++++++++++++++++++++ |
104 | 49 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
50 |
A look at the sample document gives us an idea about the various elements |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
51 |
present in the document, that we will be learning during this course. |
104 | 52 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
53 |
We shall be learning how to add the following elements to our LaTeX |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
54 |
documents. |
104 | 55 |
|
56 |
* Title, Author, Date |
|
57 |
* Abstract |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
58 |
* Sections & Subsections |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
59 |
* Appendices |
104 | 60 |
* References/Bibliography |
61 |
* Tables |
|
62 |
* Figures |
|
63 |
* Math |
|
64 |
||
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
65 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
66 |
LaTeX is not a Word Processor |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
67 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
68 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
69 |
What do we mean by LaTeX not being a Word Processor? Suppose we wanted to |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
70 |
create a simple document as shown in the image below. If one used a normal |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
71 |
word processor, the author would have to worry about setting the font sizes |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
72 |
of the fonts, centering the title, date and author information, etc. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
73 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
74 |
.. image:: images/latex_not_wp.png |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
75 |
:alt: LaTeX is not a Word Processor |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
76 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
77 |
To generate this document in LaTeX, we just tell it what we want as the |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
78 |
title, author's name, date etc. and what we want as the content. LaTeX takes |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
79 |
care of proper font size ratios and other presentation details. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
80 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
81 |
:: |
104 | 82 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
83 |
\documentclass{article} |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
84 |
\title{My First Document} |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
85 |
\author{FOSSEE} |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
86 |
\date{January 2011} |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
87 |
\begin{document} |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
88 |
\maketitle |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
89 |
Hello world! |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
90 |
\end{document} |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
91 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
92 |
LaTeX can be considered to be a document based markup language. What we mean |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
93 |
by a markup language is that you mark up pieces of your text to be particular |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
94 |
elements of your document and then a typesetter or processor typesets your |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
95 |
document based on a set of rules. What do we mean by being document-based? It |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
96 |
means, that in LaTeX, you can change the structure of the whole document |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
97 |
consistently, with a few changes in the preamble of the document, with-out |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
98 |
having to change each element separately. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
99 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
100 |
First steps -- Typesetting a minimal document |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
101 |
--------------------------------------------- |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
102 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
103 |
Let us start with a minimal example to learn how to write a LaTeX document |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
104 |
and compile it to see the **typeset** output. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
105 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
106 |
To begin, type out the following code into your text editor and save it as |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
107 |
``draft.tex``. :: |
104 | 108 |
|
109 |
\documentclass{article} |
|
110 |
\begin{document} |
|
111 |
SciPy is open-source software for mathematics, science, and engineering. |
|
112 |
\end{document} |
|
113 |
||
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
114 |
To compile your document, type the following command in your terminal:: |
104 | 115 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
116 |
$ pdflatex draft.tex |
104 | 117 |
|
118 |
This produces the output file ``draft.pdf`` |
|
119 |
||
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
120 |
Note: The ``latex`` command is often used, instead of ``pdflatex`` to get the |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
121 |
``dvi`` output. But, throughout this course, we shall use ``pdflatex`` to |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
122 |
compile our documents. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
123 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
124 |
What does it mean? |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
125 |
~~~~~~~~~~~~~~~~~~ |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
126 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
127 |
As we have already seen, LaTeX is a document based markup. The first line, |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
128 |
``\documentclass{article}``, tells that our document is an article type |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
129 |
document. LaTeX then, typesets the document accordingly. The documentclass |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
130 |
command, defines the structure and formatting of our document. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
131 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
132 |
The ``begin`` and ``end`` document commands, mark the beginning and the end |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
133 |
of the content of the LaTeX document. The text in between the begin and end |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
134 |
commands is typeset in the output document. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
135 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
136 |
A little digression |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
137 |
~~~~~~~~~~~~~~~~~~~ |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
138 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
139 |
Just like in ``bash`` and ``Python``, the commands in LaTeX are |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
140 |
case-sensitive. ``\Documentclass`` is therefore not a valid command. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
141 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
142 |
All the commands in LaTeX begin with a ``\``. An environment begins with a |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
143 |
``begin`` command and ends with an ``end`` command. In our minimal example, |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
144 |
``document`` is an environment. Only the text enclosed by the begin and end |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
145 |
commands is effected by the environment. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
146 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
147 |
So, as expected LaTeX ignores anything that is written after the |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
148 |
``\end{document}`` command. (The part of the file before the |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
149 |
``\begin{document}`` command is called the preamble, and is used to |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
150 |
*"configure"* the LaTeX typesetter and change various parameters for |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
151 |
typesetting. Details later.) |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
152 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
153 |
Essentially, anything written after the ``\end{document}`` command turns out |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
154 |
to be a comment. But, how do we write comments with in the document. ``%`` is |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
155 |
the character to indicate comments. Anything written after a ``%`` symbol in |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
156 |
a line, is ignored. For example, we can add a comment to the minimal document |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
157 |
saying, this is our first document in LaTeX, by saying ``% My First LaTeX |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
158 |
document``. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
159 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
160 |
But what if we wanted to insert the ``%`` symbol in the document? We can do |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
161 |
so by escaping it with a ``\`` (backslash). ``%`` is one of the many special |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
162 |
characters in LaTeX. The others are, ``~ # $ ^ & _ { } \``. All of them, |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
163 |
except the ``\`` itself, can be inserted by escaping it with a ``\``. To |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
164 |
insert a ``\`` in our document, we use the command ``\textbackslash``. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
165 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
166 |
What would happen if we escape a ``\`` with a ``\``? Yes, you guessed it. A |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
167 |
double backslash is actually another command. It inserts a new line in the |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
168 |
typeset document. The ``\\`` command or ``\newline`` command is used to |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
169 |
insert a newline in the output document. Line breaks in the input document, |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
170 |
do not translate into line breaks in the output document. A single line break |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
171 |
in the input document, doesn't cause any change in the output. A single empty |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
172 |
line causes a change in paragraphs in the output. (Multiple empty lines are |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
173 |
equivalent to a single empty line.) Similarly, multiple spaces are treated as |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
174 |
a single space. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
175 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
176 |
Adding Structure |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
177 |
---------------- |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
178 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
179 |
Let us now, look at giving the document some basic structure, like title, |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
180 |
sections, etc. |
104 | 181 |
|
182 |
``\documentclass`` |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
183 |
~~~~~~~~~~~~~~~~~~ |
104 | 184 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
185 |
As we have already seen, the ``documentclass`` command tells LaTeX, the type |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
186 |
of the document that we intend to create. Some of the available LaTeX classes |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
187 |
are, ``article``, ``proc``, ``report``, ``book``, ``slides``, ``letter``. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
188 |
Each class has a few differences in how the content of the document is |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
189 |
typeset. |
104 | 190 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
191 |
The ``documentclass`` command also accepts a few optional parameters. For |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
192 |
example:: |
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
193 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
194 |
\documentclass[12pt,a4paper,oneside,draft]{report} |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
195 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
196 |
``12pt`` specifies the size of the main font in the document. The relative |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
197 |
sizes of the various fonts is maintained, when the font size is changed. If |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
198 |
no size is specified, ``10pt`` is assumed by default. |
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
199 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
200 |
``a4paper`` specifies the size of the paper to be used for the document. |
56
eee394eb05fc
Added Loops section in ULT, modified LaTeX handout to use examples from sample doc.
Puneeth Chaganti <puneeth@fossee.in>
parents:
36
diff
changeset
|
201 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
202 |
``draft`` marks the hyphenation and justification problems in the document |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
203 |
with a small square in the right hand margin of the document, so that they |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
204 |
can be easily spotted. |
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
205 |
|
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
206 |
Top Matter |
104 | 207 |
---------- |
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
208 |
|
104 | 209 |
Let us begin with adding the Title, Author's name and the date to the |
210 |
document. |
|
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
211 |
|
56
eee394eb05fc
Added Loops section in ULT, modified LaTeX handout to use examples from sample doc.
Puneeth Chaganti <puneeth@fossee.in>
parents:
36
diff
changeset
|
212 |
:: |
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
213 |
|
104 | 214 |
\documentclass{article} |
215 |
\title{A Glimpse at Scipy} |
|
216 |
\author{FOSSEE} |
|
217 |
\date{June 2010} |
|
218 |
\begin{document} |
|
219 |
\maketitle |
|
220 |
SciPy is open-source software for mathematics, science, and engineering. |
|
221 |
\end{document} |
|
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
222 |
|
104 | 223 |
We add the title, the author and the date to the document before the |
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
224 |
``\begin{document}`` directive. We compile the document to see if the details |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
225 |
appear in the document, but they donot. These details do not appear in the |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
226 |
document until we use the ``\maketitle`` command with the document |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
227 |
environment to instruct LaTeX to place the top matter information into the |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
228 |
document. Now the document has these details, on compiling again. |
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
229 |
|
104 | 230 |
If no date is specified, LaTeX automatically inserts the current date. |
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
231 |
|
104 | 232 |
Abstract |
233 |
-------- |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
234 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
235 |
Next we shall add an abstract to our document. LaTeX provides an environment, |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
236 |
for adding an abstract to the document. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
237 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
238 |
:: |
104 | 239 |
|
240 |
\documentclass{article} |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
241 |
|
104 | 242 |
\title{A Glimpse at Scipy} |
243 |
\author{FOSSEE} |
|
244 |
\date{June 2010} |
|
245 |
||
246 |
\begin{document} |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
247 |
|
104 | 248 |
\maketitle |
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
249 |
|
104 | 250 |
\begin{abstract} |
251 |
This document shows a glimpse of the features of Scipy that will be explored during this course. |
|
252 |
\end{abstract} |
|
253 |
||
254 |
SciPy is open-source software for mathematics, science, and engineering. |
|
255 |
\end{document} |
|
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
256 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
257 |
The abstract environment is placed at the location where we wish it to appear |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
258 |
in the document. |
104 | 259 |
|
260 |
Sections |
|
261 |
-------- |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
262 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
263 |
Now let's look at how to add (chapters,) sections and sub-sections to our |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
264 |
document. Let's add the section headings and sub headings present in our |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
265 |
sample document to the working copy of our document. |
104 | 266 |
|
267 |
``\section``, ``\subsection``, ``\subsubsection`` |
|
268 |
||
269 |
On compiling, we can see that the headings of the sections and the |
|
270 |
sub-sections appear in the document. |
|
271 |
||
272 |
You may have noticed that LaTeX automatically numbers the sections. To |
|
273 |
prevent a section from getting numbered, an asterix is appended to the |
|
274 |
corresponding sectioning command. |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
275 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
276 |
If the document was a longer document, we could have used a report or a book |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
277 |
class. (Note: Books donot have the abstract environment.) Let's look at what |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
278 |
happens to the document, when we change it to the report class. |
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
279 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
280 |
The numbering strangely begins from zero, now. This is because, chapters have |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
281 |
an additional sectioning command called ``\chapter``. The chapter is one |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
282 |
level above a section and since, our document does not have a ``\chapter`` |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
283 |
command, the sections are numbered from 0. To change this, we add a chapter |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
284 |
command before the first section. We say |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
285 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
286 |
:: |
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
287 |
|
104 | 288 |
\chapter{One} |
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
289 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
290 |
Now, observe that we now have a chapter title appearing and the numbering |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
291 |
starting from 1. |
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
292 |
|
104 | 293 |
Also, note that the subsubsections donot get a numbering now. This is |
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
294 |
controlled by a variable called the secnumdepth. By default it is set to 2. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
295 |
We can now, change it to 3 and get numbering for subsubsections also. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
296 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
297 |
:: |
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
298 |
|
104 | 299 |
\setcounter{secnumdepth}{3} |
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
300 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
301 |
What do you expect to happen if we changed the secnumdepth to 1? What if it |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
302 |
is 0 or -1? |
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
303 |
|
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
304 |
|
104 | 305 |
Appendix |
306 |
-------- |
|
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
307 |
|
104 | 308 |
Notice that our document also has an appendix. Let's add an appendix |
309 |
to our document. |
|
310 |
||
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
311 |
:: |
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
312 |
|
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
313 |
\appendix |
104 | 314 |
\section{Plotting using Pylab} |
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
315 |
|
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
316 |
Table of Contents |
104 | 317 |
----------------- |
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
318 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
319 |
Our sample document is not long enough to warrant a table of contents, but |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
320 |
let us learn to add a table of contents to a LaTeX document. If you ever |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
321 |
tried adding a table of contents, to a document in a wordprocessor, you would |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
322 |
know how much of a trouble it is. In LaTeX, it is a matter of just one |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
323 |
command and placing the command at the location where you would want to have |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
324 |
the table of contents. Let's now add a table of contents to our draft. Now, |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
325 |
compile the document and look at the output document. It does not have the |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
326 |
table of contents! |
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
327 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
328 |
On the first compilation only the "Contents" heading appears in the document, |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
329 |
but the actual table does not appear. You will need to compile your document |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
330 |
once more, for the actual table to appear in your document. On the first run, |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
331 |
LaTeX has gone through your document and generated a temporary file |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
332 |
(``.toc``), with the entries that should go into the table of contents. These |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
333 |
entries are made, when you compile your document for the second time. |
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
334 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
335 |
Note that any section/block that has been numbered automatically appears in |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
336 |
the table of contents. It is possible to get un-numbered sections, for |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
337 |
instance a Preface or a Foreword section to appear in the Table of Contents. |
104 | 338 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
339 |
Let's change our Introduction section to be an un-numbered one and try to |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
340 |
make it appear in the table-of-contents. :: |
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
341 |
|
104 | 342 |
\section*{Introduction} |
343 |
\addcontentsline{toc}{section}{Intro} |
|
344 |
||
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
345 |
We shall talk about adding and managing bibliographies, later in the course. |
104 | 346 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
347 |
Now, that we have the basic structure of the document, let's get into the |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
348 |
content and the details of it. |
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
349 |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
350 |
Typesetting Text |
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
351 |
---------------- |
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
352 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
353 |
Let's begin with adding the second paragraph to the introduction section. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
354 |
Let's place the text of the second para, after the first line, that we |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
355 |
already have. Now, compile the document. |
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
356 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
357 |
As already discussed, we need to an insert an empty line, to insert a new |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
358 |
paragraph in LaTeX. Also, notice that the new paragraph is indented. |
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
359 |
|
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
360 |
Quotation Marks |
104 | 361 |
--------------- |
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
362 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
363 |
Look at the quotation marks around the text, Sigh Pie. They are not formatted |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
364 |
properly. To place quotation marks in LaTeX, you should use ````` character |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
365 |
for the left quote & ``'`` character for the right quote. For double quotes, |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
366 |
they should be used twice. |
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
367 |
|
104 | 368 |
Fonts |
369 |
----- |
|
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
370 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
371 |
The names of the software tools, Scilab, Matlab, etc. appear in italics or |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
372 |
emphasized as it is called in LaTeX. To emphasize text, the ``\emph`` command |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
373 |
is used. |
104 | 374 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
375 |
Let's also add the contents of the subsection "Sub-packages of Scipy". We |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
376 |
shall add the table as plain text, until we learn how to edit tables. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
377 |
|
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
378 |
Let's try and form a tabular structure by separating the left and right |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
379 |
columns using spaces. On compiling we find that LaTeX doesn't add multiple |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
380 |
spaces between words. Just like multiple empty lines, multiple spaces are |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
381 |
considered as a single space. |
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
382 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
383 |
Also, we notice that ``LaTeX`` starts a new paragraph at the beginning of the |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
384 |
table. To avoid this, we use the ``flushleft`` environment. |
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
385 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
386 |
The names of the sub-packages appear in a fixed width font in the sample |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
387 |
document provided to us. The headings of the columns appear in bold-face. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
388 |
Let's make changes to this effect. |
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
389 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
390 |
``\textbf`` is used to change text to bold face and ``\texttt`` is used to |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
391 |
change text to fixed width font. |
56
eee394eb05fc
Added Loops section in ULT, modified LaTeX handout to use examples from sample doc.
Puneeth Chaganti <puneeth@fossee.in>
parents:
36
diff
changeset
|
392 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
393 |
We could also change the separating - (hyphen) to an em-dash (or en-dash) -- |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
394 |
is em-dash and --- is an em-dash, to improve the appearance of the document. |
56
eee394eb05fc
Added Loops section in ULT, modified LaTeX handout to use examples from sample doc.
Puneeth Chaganti <puneeth@fossee.in>
parents:
36
diff
changeset
|
395 |
|
104 | 396 |
Lists |
397 |
----- |
|
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
398 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
399 |
The section on Use of Scipy in this course, contains lists. Let's now add |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
400 |
lists to our document. The ``enumerate`` environment adds numbered lists to |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
401 |
our document and the ``itemize`` environment adds un-numbered lists. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
402 |
``\item`` command adds a new entry to a list. Note, that LaTeX can easily |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
403 |
handle nested lists. In fact most environments can be embedded within other |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
404 |
environments, without any problems. |
104 | 405 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
406 |
LaTeX also has a description list, which shall be an exercise, for you. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
407 |
|
104 | 408 |
|
409 |
Footnotes, Labels and References |
|
410 |
-------------------------------- |
|
411 |
||
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
412 |
Let's now add the footnote to pylab. LaTeX provides a footnote command to add |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
413 |
a footnote. |
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
414 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
415 |
We added the footnote with Appendix A, as plain text. But, in case we added |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
416 |
another Appendix before the section on using ``pylab``, the footnote will |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
417 |
have to be edited. To avoid this, LaTeX provides a handy system of labels and |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
418 |
referencing. |
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
419 |
|
104 | 420 |
We first add a label to the section that we want to refer in this |
421 |
footnote. Then, we change the footnote, and add the reference to this |
|
422 |
label instead of the character A. If you look at the output after |
|
423 |
compiling the document once, you will see that the footnote has |
|
424 |
question marks instead of the section number. You will have to |
|
425 |
compile once again, for the section number to appear in the footnote. |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
426 |
|
104 | 427 |
|
428 |
Including code |
|
429 |
-------------- |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
430 |
|
104 | 431 |
In the footnote above, and in the table for the sub-packages list, we |
432 |
used the ``\texttt`` command to get a fixed width font. But we could |
|
433 |
instead use an environment provided by LaTeX to include pre-formatted |
|
434 |
text or code. LaTeX by default provides the verbatim environment to |
|
435 |
include pre-formatted text. You can try that out during the lab |
|
436 |
session. We shall look at using the listings package, specifically |
|
437 |
meant for including code in our document. |
|
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
438 |
|
104 | 439 |
First of all you need to tell LaTeX, that you want to use the listings |
440 |
package in your document. We add the directive |
|
441 |
``\usepackage{listings}`` to the preamble of our document. |
|
442 |
||
443 |
Then we set the language of the code that we are going to embed into |
|
444 |
our document. For this we use the lstset command. :: |
|
445 |
||
446 |
\lstset{language=Python, |
|
447 |
showstringspaces=false,} |
|
448 |
||
449 |
The listings package allows you to use color and do a lot of things |
|
450 |
with your embedded code, but all that during a lab exercise. |
|
451 |
||
452 |
Now, to put a line of code, inline and not as a separate block, we use |
|
453 |
the ``\lstinline`` command. We change the name pylab in the footnote |
|
454 |
to use lstinline instead of the texttt. To embed a block of code, we |
|
455 |
use the lstlisting environment (``\begin{lstlisting}`` and |
|
456 |
``\end{lstlisting}``). For example, let's add the code to the Appendix |
|
457 |
of our document. |
|
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
458 |
|
104 | 459 |
Figures, Tables and Floats |
460 |
-------------------------- |
|
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
461 |
|
104 | 462 |
Let's now add the figure, to the appendix. |
463 |
||
464 |
To include graphics in a LaTeX document, we need to use the graphicx |
|
465 |
package. Add the ``\usepackage{graphicx}`` directive to the preamble |
|
466 |
of the document. |
|
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
467 |
|
104 | 468 |
To add the graphic, use the ``includegraphics`` command. The relative |
469 |
path of the image that we wish to include is passed as an argument to |
|
470 |
includegraphics. It takes an optional argument of scaling the |
|
471 |
image. We use a scale of 0.4 to scale our image. |
|
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
472 |
|
104 | 473 |
It takes other optional arguments. |
474 |
||
475 |
``width=x``, ``height=x`` |
|
476 |
If only the height or width is specified, |
|
477 |
the image is scaled, maintaining the aspect ratio. |
|
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
478 |
|
104 | 479 |
``keepaspectratio`` |
480 |
This parameter can either be set to true or false. When set to |
|
481 |
true, the image is scaled according to both width and height, |
|
482 |
without changing the aspect ratio, so that it does not exceed both |
|
483 |
the width and the height dimensions. |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
484 |
|
104 | 485 |
``angle=x`` |
486 |
This option can be used to rotate the image by ``x`` degrees, |
|
487 |
counter-clockwise. |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
488 |
|
104 | 489 |
Figures (and tables) are treated specially because, they cannot be |
490 |
broken across pages. They are "floated" across to the next page, if |
|
491 |
they donot fit on the current page, filling the current page with |
|
492 |
text. |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
493 |
|
104 | 494 |
To make our graphic into a float, we should enlose it within a figure |
495 |
environment. For a table, the table environment should be used. We now |
|
496 |
move our graphic into a figure environment. The figure environment |
|
497 |
takes an additional parameter for the location of the |
|
498 |
float. ``\begin{figure}[hbtp!]``. The specifiers ``htbp`` are |
|
499 |
permissions to place the float at various locations. ``t`` for top of |
|
500 |
page, ``b`` for bottom of page, ``p`` for a separate page for floats |
|
501 |
and ``h`` for here, as in the same place where the command appears in |
|
502 |
the source. ``!`` mark overrides a few of LaTeX's internal parameters |
|
503 |
for good position of floats. |
|
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
504 |
|
104 | 505 |
The figure environment also, allows us to add a caption to the graphic |
506 |
using the ``\caption`` command. |
|
507 |
||
508 |
To place the graphic in the center aligned in the page, we use the |
|
509 |
center environment. |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
510 |
|
104 | 511 |
To label a figure, we just add a label with in the figure |
512 |
environment. Note, that the label to a figure should be added after |
|
513 |
the caption command. Also, note that tables are auto-numbered. |
|
56
eee394eb05fc
Added Loops section in ULT, modified LaTeX handout to use examples from sample doc.
Puneeth Chaganti <puneeth@fossee.in>
parents:
36
diff
changeset
|
514 |
|
104 | 515 |
Let us finish the appendix, by adding the content present at the |
516 |
beginning of the appendix. The bibliographic citations will be dealt |
|
517 |
with later. |
|
56
eee394eb05fc
Added Loops section in ULT, modified LaTeX handout to use examples from sample doc.
Puneeth Chaganti <puneeth@fossee.in>
parents:
36
diff
changeset
|
518 |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
519 |
Tables |
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
520 |
~~~~~~ |
56
eee394eb05fc
Added Loops section in ULT, modified LaTeX handout to use examples from sample doc.
Puneeth Chaganti <puneeth@fossee.in>
parents:
36
diff
changeset
|
521 |
|
104 | 522 |
Now, let us look at the other kind of floats - Tables. We shall |
523 |
convert the list of sub-packages in the sub-packages section to a |
|
524 |
table. |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
525 |
|
104 | 526 |
To begin a table, we use the tabular environment. And to make this a |
527 |
float, it is enclosed in the table environment. The table environment |
|
528 |
also allows us to add captions to the table and Tables are also auto |
|
529 |
numbered. |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
530 |
|
104 | 531 |
The tabular environment takes as arguments the columns and the |
532 |
formatting of each column. The possible arguments to the tabular |
|
533 |
environment are |
|
56
eee394eb05fc
Added Loops section in ULT, modified LaTeX handout to use examples from sample doc.
Puneeth Chaganti <puneeth@fossee.in>
parents:
36
diff
changeset
|
534 |
|
eee394eb05fc
Added Loops section in ULT, modified LaTeX handout to use examples from sample doc.
Puneeth Chaganti <puneeth@fossee.in>
parents:
36
diff
changeset
|
535 |
+---------------+------------------------------------+ |
eee394eb05fc
Added Loops section in ULT, modified LaTeX handout to use examples from sample doc.
Puneeth Chaganti <puneeth@fossee.in>
parents:
36
diff
changeset
|
536 |
| ``l`` | left justified column content | |
eee394eb05fc
Added Loops section in ULT, modified LaTeX handout to use examples from sample doc.
Puneeth Chaganti <puneeth@fossee.in>
parents:
36
diff
changeset
|
537 |
+---------------+------------------------------------+ |
eee394eb05fc
Added Loops section in ULT, modified LaTeX handout to use examples from sample doc.
Puneeth Chaganti <puneeth@fossee.in>
parents:
36
diff
changeset
|
538 |
| ``r`` | right justified column content | |
eee394eb05fc
Added Loops section in ULT, modified LaTeX handout to use examples from sample doc.
Puneeth Chaganti <puneeth@fossee.in>
parents:
36
diff
changeset
|
539 |
+---------------+------------------------------------+ |
eee394eb05fc
Added Loops section in ULT, modified LaTeX handout to use examples from sample doc.
Puneeth Chaganti <puneeth@fossee.in>
parents:
36
diff
changeset
|
540 |
| ``c`` | centered column content | |
eee394eb05fc
Added Loops section in ULT, modified LaTeX handout to use examples from sample doc.
Puneeth Chaganti <puneeth@fossee.in>
parents:
36
diff
changeset
|
541 |
+---------------+------------------------------------+ |
eee394eb05fc
Added Loops section in ULT, modified LaTeX handout to use examples from sample doc.
Puneeth Chaganti <puneeth@fossee.in>
parents:
36
diff
changeset
|
542 |
| ``|`` | produces a vertical line. | |
eee394eb05fc
Added Loops section in ULT, modified LaTeX handout to use examples from sample doc.
Puneeth Chaganti <puneeth@fossee.in>
parents:
36
diff
changeset
|
543 |
+---------------+------------------------------------+ |
eee394eb05fc
Added Loops section in ULT, modified LaTeX handout to use examples from sample doc.
Puneeth Chaganti <puneeth@fossee.in>
parents:
36
diff
changeset
|
544 |
|
104 | 545 |
It also takes an optional parameter that specifies the position of the |
546 |
table; ``t`` for top, ``b`` for bottom, or ``c`` for center. |
|
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
547 |
|
104 | 548 |
Each column of a table is separated by an ``&`` symbol and each row is |
549 |
separated by a new line. The ``\hline`` command allows you to draw |
|
550 |
horizontal lines between two rows of the table. But it does not allow |
|
551 |
you do draw partial lines. ``\cline{a-b}`` draws a horizontal line |
|
552 |
from column ``a`` to column ``b``. |
|
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
553 |
|
104 | 554 |
We also add a label to the table and refer to it in the first line of |
555 |
the section. |
|
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
556 |
|
104 | 557 |
You could also add a listoftables or listoffigures to the document, |
558 |
similar to the way we added table of contents. |
|
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
559 |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
560 |
Typesetting Math |
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
561 |
---------------- |
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
562 |
|
104 | 563 |
Now we shall move to typesetting the Math in the sample document given |
564 |
to us. We shall start with the Matrices subsection. |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
565 |
|
104 | 566 |
In general, it is advised to use the AMS-LaTeX bundle to typeset |
567 |
mathematics in LaTeX. AMS-LaTeX is a collection of packages and |
|
568 |
classes for mathematical typesetting. |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
569 |
|
104 | 570 |
We load ``amsmath`` by issuing the ``\usepackage{amsmath}`` in the |
571 |
preamble. Through out this section, it is assumed that the ``amsmath`` |
|
572 |
package has been loaded. |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
573 |
|
104 | 574 |
Let's now typeset the matrix A. |
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
575 |
|
104 | 576 |
To typeset math, we just have to enclose it within ``\(`` and ``\)`` |
577 |
or a pair of ``$`` signs. |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
578 |
|
104 | 579 |
To typeset the matrix A, we use the ``bmatrix`` environment. It works |
580 |
similar to a tabular environment - ``&`` is used to demarcate columns |
|
581 |
and ``\\`` is used to add a new row. ``bmatrix`` environment gives the |
|
582 |
``[`` ``]`` as delimiters. There are 5 other matrix environments |
|
583 |
giving matrices with other delimiters - ``matrix`` (none), ``pmatrix`` |
|
584 |
``(``, ``Bmatrix`` ``{``, ``vmatrix`` ``|`` and ``Vmatrix`` ``||``. |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
585 |
|
104 | 586 |
To write the name of the matrix A, a bold-faced A is used. This is |
587 |
obtained by using the ``\mathbf`` command. |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
588 |
|
104 | 589 |
This subsection doesn't have much more math. The next section on |
590 |
inverse doesn't have anything new except for writing inverse of A. |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
591 |
|
104 | 592 |
To typeset superscripts in LaTeX, the ``^`` character is used. The |
593 |
carat operator just acts on the next character. To have multiple |
|
594 |
characters as superscript they must be enclosed in ``{ }``. Similarly |
|
595 |
for typesetting text as subscripts the ``_`` character is used. |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
596 |
|
104 | 597 |
To typeset the summation symbol, use the command ``\sum.`` The upper |
598 |
and lower limits are specified using the ``^`` and ``_`` |
|
599 |
characters. Similarly, the integral symbol is obtained using the |
|
600 |
``\int`` command. |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
601 |
|
104 | 602 |
Next, let us type in the equation present in the section on |
603 |
Determinants. Note that it is different from all the math we've typed |
|
604 |
until now, since it is not inline and is "displayed", in the LaTeX |
|
605 |
lingo. LaTeX has a number of environments for displaying equations, |
|
606 |
with minor subtle differences. In general use ``\[`` ``\]`` to typeset |
|
607 |
displayed equations without numbering them. ``\begin{equation*}`` is |
|
608 |
equivalent to it. To obtain numbered equations use |
|
609 |
``\begin{equation}``. |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
610 |
|
104 | 611 |
Next we wish to typeset a group of equations. The equation environment |
612 |
does not accept ``\\`` to get a new line. For multiple equations |
|
613 |
amsmath has a handful of environments with subtle differences. We |
|
614 |
shall use the ``eqnarray`` environment. ``eqnarray*`` environment |
|
615 |
gives unnumbered equations, as expected. The ``eqnarray`` environment |
|
616 |
works similar to a table environment. The parts of the equation that |
|
617 |
need to be aligned are indicated using an ``&`` symbol. The |
|
618 |
``newline`` command is used to enter a every new equation after the |
|
619 |
first one. We now typeset the equations in the section on linear |
|
620 |
equations using the ``eqnarray`` environment. (The equations in the |
|
621 |
determinants section use ``eqnarray*``) |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
622 |
|
104 | 623 |
We next typeset the math in the section on polynomials. To typeset |
624 |
fractions use the ``\frac`` command. To typeset surds, we use the |
|
625 |
``\sqrt`` command with the optional paramter of ``[n]``. |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
626 |
|
104 | 627 |
Inserting Greek letters into LaTeX is simple. ``\alpha``, ``\beta``, |
628 |
``\gamma``, ... on for small letters and ``\Alpha``, ``\Beta``, |
|
629 |
``\Gamma``, ... for capital. |
|
630 |
||
631 |
Also, math environments do not give extra spaces using the space or |
|
632 |
tab characters. The following commands are available to specify the |
|
633 |
spacing required. |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
634 |
|
104 | 635 |
+---------+--------------------+---------+ |
636 |
| Abbrev. | Spelled out | Example | |
|
637 |
+---------+--------------------+---------+ |
|
638 |
| ``\,`` | ``\thinspace`` | | |
|
639 |
+---------+--------------------+---------+ |
|
640 |
| ``\:`` | ``\medspace`` | | |
|
641 |
+---------+--------------------+---------+ |
|
642 |
| ``\;`` | ``\thickspace`` | | |
|
643 |
+---------+--------------------+---------+ |
|
644 |
| | ``\quad`` | | |
|
645 |
+---------+--------------------+---------+ |
|
646 |
| | ``\qquad`` | | |
|
647 |
+---------+--------------------+---------+ |
|
648 |
| ``\!`` | ``\negthinspace`` | | |
|
649 |
+---------+--------------------+---------+ |
|
650 |
| | ``\negmedspace`` | | |
|
651 |
+---------+--------------------+---------+ |
|
652 |
| | ``\negthickspace`` | | |
|
653 |
+---------+--------------------+---------+ |
|
101
e529bec52b6f
Revised latex handout for new sees course; will drop this and make it more need based.
Puneeth Chaganti <punchagan@gmail.com>
parents:
63
diff
changeset
|
654 |
|
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
655 |
Bibliography |
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
656 |
------------ |
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
657 |
|
104 | 658 |
Let's now look at how to write bibliography and cite references. |
36
4c4c8a9795b2
Edited Arrays & Matrices and Bibliography sections.
Puneeth Chaganti <puneeth@fossee.in>
parents:
30
diff
changeset
|
659 |
|
104 | 660 |
Writing bibliographies in LaTeX using the ``thebibliography`` |
661 |
environment is pretty easy. You simply have to list down all the |
|
662 |
bibliography items within the bibliography environment. |
|
56
eee394eb05fc
Added Loops section in ULT, modified LaTeX handout to use examples from sample doc.
Puneeth Chaganti <puneeth@fossee.in>
parents:
36
diff
changeset
|
663 |
|
104 | 664 |
Each entry of the bibliography begins with the command |
665 |
``\bibitem[label]{name}``. The name is used to cite the bibliography |
|
666 |
item within the document using ``\cite{name}``. The label option |
|
667 |
replaces the numbers from the auto enumeration with the labels given. |
|
36
4c4c8a9795b2
Edited Arrays & Matrices and Bibliography sections.
Puneeth Chaganti <puneeth@fossee.in>
parents:
30
diff
changeset
|
668 |
|
104 | 669 |
The ``9`` passed as an argument to ``thebibliography`` command |
670 |
indicates the maximum width of the label that the references will |
|
671 |
have. In our sample document, we have less than 10 items in the |
|
672 |
Bibliography and therefore we use 9. |
|
36
4c4c8a9795b2
Edited Arrays & Matrices and Bibliography sections.
Puneeth Chaganti <puneeth@fossee.in>
parents:
30
diff
changeset
|
673 |
|
104 | 674 |
Presentations with Beamer |
675 |
------------------------- |
|
36
4c4c8a9795b2
Edited Arrays & Matrices and Bibliography sections.
Puneeth Chaganti <puneeth@fossee.in>
parents:
30
diff
changeset
|
676 |
|
104 | 677 |
Using beamer for you presentations is a good idea, since you can use |
678 |
the LaTeX that you have used for the report/document for the |
|
679 |
presentation as well. |
|
36
4c4c8a9795b2
Edited Arrays & Matrices and Bibliography sections.
Puneeth Chaganti <puneeth@fossee.in>
parents:
30
diff
changeset
|
680 |
|
104 | 681 |
To write a ``beamer`` presentation, it is recommended that we use one |
682 |
of the templates that beamer provides. We shall use the |
|
683 |
``speaker_introduction`` template to get started with beamer. |
|
36
4c4c8a9795b2
Edited Arrays & Matrices and Bibliography sections.
Puneeth Chaganti <puneeth@fossee.in>
parents:
30
diff
changeset
|
684 |
|
104 | 685 |
As you can see, the document begins with the ``documentclass`` being |
686 |
set to beamer. |
|
36
4c4c8a9795b2
Edited Arrays & Matrices and Bibliography sections.
Puneeth Chaganti <puneeth@fossee.in>
parents:
30
diff
changeset
|
687 |
|
104 | 688 |
``\usetheme`` command sets the theme to be used in the presentation. |
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
689 |
|
104 | 690 |
``\usecolortheme`` command sets the color theme of the presentation. |
56
eee394eb05fc
Added Loops section in ULT, modified LaTeX handout to use examples from sample doc.
Puneeth Chaganti <puneeth@fossee.in>
parents:
36
diff
changeset
|
691 |
|
104 | 692 |
Notice that each slide is enclosed within ``\begin{frame}`` and |
693 |
``\end{frame}`` commands. The ``\begin{frame}`` command can be passed |
|
694 |
the Title and Subtitle of the slide as parameters. |
|
56
eee394eb05fc
Added Loops section in ULT, modified LaTeX handout to use examples from sample doc.
Puneeth Chaganti <puneeth@fossee.in>
parents:
36
diff
changeset
|
695 |
|
104 | 696 |
The title page of the presentation can be set like any other LaTeX |
697 |
document. |
|
56
eee394eb05fc
Added Loops section in ULT, modified LaTeX handout to use examples from sample doc.
Puneeth Chaganti <puneeth@fossee.in>
parents:
36
diff
changeset
|
698 |
|
104 | 699 |
To do overlays, use the ``\pause`` command. It does sequential |
700 |
overlays. Non sequential overlays can also be done. (Lab exercise.) |
|
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
701 |
|
104 | 702 |
If you have fragile environments like ``verbatim`` or ``lstlisting``, |
703 |
you need to give the frame an optional parameter ``[fragile]``. |
|
30
3ca8ab883c13
First Draft of LaTeX handout added.
Puneeth Chaganti <puneeth@fossee.in>
parents:
diff
changeset
|
704 |
|
104 | 705 |
To achieve more with beamer, it is highly recommended that you look at |
706 |
the ``beameruserguide``. |
|
56
eee394eb05fc
Added Loops section in ULT, modified LaTeX handout to use examples from sample doc.
Puneeth Chaganti <puneeth@fossee.in>
parents:
36
diff
changeset
|
707 |
|
157
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
708 |
.. |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
709 |
Local Variables: |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
710 |
mode: rst |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
711 |
indent-tabs-mode: nil |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
712 |
sentence-end-double-space: nil |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
713 |
fill-column: 77 |
3174d4803cd5
latex: Changes to slides and handout before and after class.
Puneeth Chaganti <punchagan@fossee.in>
parents:
104
diff
changeset
|
714 |
End: |