1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
.. Objectives
.. ----------
.. By the end of this tutorial, you will be able to
.. 1. Understand basic structure of a LaTeX document, its various document
.. classes and loading packages that add new features to the LaTeX system.
.. #. Create a LaTeX document with a title and an abstract.
.. #. Create numbered and non-numbered sections and subsections in a LaTeX
.. document.
.. #. Create an appendix in a LaTeX document.
.. #. Create a table of content in a LaTeX document.
.. Prerequisites
.. -------------
.. 1. latex_intro
.. Author : Harish Badrinath < harish [at] fossee [dot] in >
Internal Reviewer :
External Reviewer :
Langauge Reviewer :
Checklist OK? : <put date stamp here, if OK>
Script
------
.. L1
{{{ Show the first slide containing title, name of the production
team along with the logo of MHRD }}}
.. R1
Hello friends and welcome to the tutorial on Basics of LaTeX and its document
structure.
.. L2
{{{ Show the objectives slide }}}
.. R2
.. By the end of this tutorial, you will be able to
.. 1. Understand basic structure of a LaTeX document, its various document
.. classes and loading packages that add new features to the LaTeX system.
.. #. Create a LaTeX document with a title and an abstract.
.. #. Create numbered and non-numbered sections and subsections in a LaTeX
.. document.
.. #. Create an appendix in a LaTeX document.
.. #. Create a table of content in a LaTeX document.
.. L3
{{{ Switch to the pre-requisite slide }}}
.. R3
Before beginning this tutorial,we would suggest having a working installation of
LaTeX and suggest you to complete the tutorial titled "Introduction to LaTeX".
.. L4
{{{ Basic Structure of a LaTeX document }}}
\documentclass{article}
\begin{document}
SAMPLE TEXT
\end{document}
.. R4
the text "SAMPLE TEXT" is illustrative and can be replaced replaced by a
single alpha-numeric character, for example. When done so, the resulting
document could be described as the shortest possible LaTeX input document, that
creates an output file. It consists of 3 LaTeX commands and one line/character
of text.
This is processed by a TeX processor that generates an output file. Now, we
begin to look into each line in the example in more detail.
The first line reads
.. L5
\documentclass{article}
.. R5
which more generally can be written as
.. L6
\documentclass [parameters] {DocumentClass}
.. R6
Where \documentclass is a LaTeX command.
Parameters specify if you want to use a non default font size, for example.
More specifically the parameters can be used to alter things like font size of
the document, paper size, two sided or single sided printing, etc.
.. L7
\documentclass[12pt,a4paper,draft]{report}
.. R7
This command instructs LaTeX to
Create a new document of class report. The available classes are article, proc,
report, book, slides, letter.
12 pt: sets the font size of main font. Other are relatively adjusted. 10pt is
the default.
a4paper: specifies the paper size
draft: marks hyphenation and justification problems in typesetting
with a square in the margin
.. L8
\usepackage[options]{...}
.. R8
This statement can be used optionally and is used to include packages, which are
used to extend the LaTeX's capabilities. There are a number of packages that are
included by default with LaTeX2 base distribution. You can use the texdoc
command for accessing package documentation.
.. L9
::
\documentclass{article}
\title{My First LaTeX Document}
\author{Harish}
\date
\begin{document}
Hello world!
\end{document}
.. R9
We add the LaTeX commands, that specify the title and the author of the
document. When we compile the document shown to an output file and view it we
notice that output is, as seen no different from not adding the fields of title
and author. We need to add another command to actually show the title author
and date in the output document. We add the command in the following example.
.. L10
\documentclass{article}
\title{My First LaTeX Document}
\author{Harish}
\begin{document}
\maketitle
Hello world!
\end{document}
.. R10
The command \maketitle adds title, authors name and date to the output file.
Of these only the date is optional. If date command is specified, then the given
date is used else today's date is used.
.. L11
\documentclass{article}
\title{My First LaTeX Document}
\author{Harish}
\begin{document}
\maketitle
Hello world!
\begin{abstract}
An Example Abstract
\end{abstract}
\end{document}
.. R11
The abstract command is used to insert abstract of a document, into the output
file.Place it in the location, where you want your abstract to present in
the document. It is available for the document classes article and report, but
not book
.. L12
\documentclass{article}
\title{My First LaTeX Document}
\author{Harish}
\begin{document}
\maketitle
Hello world!
\begin{abstract}
An Example Abstract
\end{abstract}
\section{Numbered Section 1}
Section1 Text
\section{Numbered Section 2}
Section2 Text
\section*{Unnumbered Section 1}
Section3 Text
\section*{Unnumbered Section 2}
Section4 Text
\end{document}
.. R12
Titles chapters and sections are used to help the user find his or her way
through your work. The following commands are available in the article class:
section, subsection, subsubsection, paragraph and sub paragraph. The default
behavior is to use numbered sections. We can use un-numbered sections appending
* to section command. If you want to split your document without influencing the
section or chapter numbering use the part command.
.. L13
\documentclass{book}
\title{My first Book}
\author{Harish}
\date{31-February-2012}
\begin{document}
\maketitle
\chapter{My First Chapter}
Main
\section{Section1}
Section 1 Text
\subsubsection{My First Subsection}
Numbered-Section 1's Subsection Text
\section{Section2}
Numbered-Section 2 Text
\section*{Section3}
First un-numbered Section Text
\section*{Section4}
Second un-numbered Section Text
\chapter{So We say goodbye}
Thank you for reading dear reader
\end{document}
.. R13
Longer documents can use report or book class. We can add a new chapter using
the chapter command, provided by the report or book class. After compiling the
file shown in the slide we notice that subsections are not numbered.
.. L14
\setcounter{secnumdepth}{3}
.. R14
We can change this behavior with the command setcounter , calling it as shown
in the slide.
.. L15
\appendix
.. R15
Appendix can be added to the document using \appendix command. any content after
\appendix will be added to the appendix. In the report or book class, we have to
use \chapter to indicate that the chapters are to be numbered as appendices.
similarly for the article class we have to use the section command to indicate
that sections are to be numbered as appendices.
.. L16
.. R16
Lets add a Table of content to the document. The LaTeX command to add a TOC to a
document is using \tableofcontents command. It is used at the point at which the
table of content is to be placed. You then have to compile the input file twice
to produce a text.
Any numbered section/chapter appear automatically in the table of content.
.. L17
.. R17
Un-numbered sections are added to TOC using \addcontentsline command.
For example we use the command
\addcontentsline{toc}{section}{Intro}
where intro is the text that you want to appear in the Table of contents.
.. L18
{{{ Show summary slide }}}
.. R18
This brings us to the end of this tutorial. In this tutorial, we have,
.. 1. Gained an understanding of the basic structure of a LaTeX document, its
.. various document classes and loading packages that add new features to
.. the LaTeX system.
.. #. Created a LaTeX document with a title and an abstract.
.. #. Created both numbered and non-numbered sections and subsections in a
.. LaTeX document.
.. #. Created an appendix in a LaTeX document.
.. #. Created a table of content in a LaTeX document.
.. L19
{{{Show self assessment questions slide}}}
.. R19
Here are some self assessment questions for you to solve
1. Is the LaTeX code given below a valid input file (File compiles successfully
and produces the intended result, that is to produce a book with two chapters
and an appendix.
\begin{verbatim}
\documentclass{book}
\title{My first Book}
\author{Harish}
\date{31-February-2012}
\begin{document}
\maketitle
\chapter{My First Chapter}
Main
\chapter{So We say goodbye}
Thank you for reading dear reader
\appendix
\section{First Appendix}
\end{document}
\end{verbatim}
2. Does making the subsections placed at any arbitrary level, get numbered by
default using the appropriate setcounter command with secnumdepth parameter
make the subsections appear automatically in the table of content ??
.. L20
{{{Show self assessment questions slide}}}
.. R20
And the answers,
1. Although the given file looks syntactically valid, the output file is not what
we expected. This is mainly because we are trying to use the section command to
create sections in the appendix, for a document whose type is given as a book.
2. No The \tableofcontents command normally shows only numbered section
headings, and only down to the level defined by the tocdepth counter.
.. L21
{{{ Show the thankyou slide }}}
.. R21
Hope you have enjoyed this tutorial and found it useful.
Thank you!
|