Professional Documents
Culture Documents
Contents
1 Organising the document 1
1.1 Segregation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Demonstrating the declarations . . . . . . . . . . . . . . . . . . . 1
1.3 Referencing and Table of Contents . . . . . . . . . . . . . . . . . 2
1.3.2 TOC: Adjusting Depth . . . . . . . . . . . . . . . . . . . 2
2 Page Layout 4
4 Indices 7
4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4.2 Basic Indices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4.3 Entries & Sub-entries . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.4 Formatting the Index . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.5 Including Index in the TOC . . . . . . . . . . . . . . . . . . . . . 11
5 Multiple Columns 11
5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.2 Multicol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Document Index 14
Basic Document Formatting Section 1
Since this is a relatively small document, we have used the article document
class. \part and \chapter are only available in the book and report document
classes.
As you go deeper, you have \paragraph and \subparagraph as well. Although
they aren’t ordered, they can show up in the table of contents with the appro-
priate setting. More on that later.
5 \ s u b s u b s e c t i o n { Sample S u b s u b s e c t i o n }
6 \ l a b e l { sample }
7 Hey . Why a r e you r e a d i n g t h i s ? Go ahead t o t h e next
s u b s u b s e c t i o n . I t kinda sounds funny when you r e a d i t
a l o u d though .
8
9 \ s u b s u b s e c t i o n {The s t r a i g h t f o r w a r d code }
10 \ l a b e l { s t r a i g h t f o r w a r d =code }
11 Here i s what t h e code l o o k s l i k e . The code we show w i l l
o n l y t y p e s e t upto t h i s s e n t e n c e .
3 \ s u b s u b s e c t i o n {TOC: A d j u s t i n g Depth}
Right before the point where you want a change in depth, make the above
declaration.
Now, before proceeding to the next section, we will set the depth back to 2, so
that subsubsections will no longer show up in the Table of Contents (just like
before).
1 \ addtocontents{ t o c }
2 {\ setcounter { t o c d e p t h }{2}}
3 \ section { Page Layout }
2 Page Layout
The geometry package makes adjusting the page layout in terms of paper size
and margins very convenient.
A typical declaration in the preamble would look something like:
1 \usepackage [ a 4 paper , hmargin=1in , vmargin =1.5 i n ] { geometry }
2 %We want A4 paper , and have s p e c i f i e d h o r i z o n t a l and
v e r t i c a l margins r e s p e c t i v e l y .
This setting is the default for the document. Now, for some reason, you may
want to change the margins for a few consecutive pages, and then revert to the
original settings specified in the preamble. It is here that the \newgeometry{}
and \restoregeometry commands prove useful. These commands are only
available within the document environment.
For example,
1 %t h e above l a y o u t L1 d e c l a r e d i n t h e preamble .
2 \ begin{ document }
3
4 %c o n t e n t i n l a y o u t L1
5
16 \ restoregeometry
17 %\ c l e a r p a g e d e c l a r e d i m p l i c i t l y
18
21 \end{ document }
This is just a guide to get you motivated, the complete arsenal of nuanced
options the geometry package provides is documented here.
8 \ f a n c y h f {} %c l e a r s t h e d e f a u l t h e a d e r and f o o t e r t h a t
appear a s p a r t o f t h e p l a i n s t y l e
9
15 \ l h e a d { B a s i c Document Formatting } %l e f t o f t h e h e a d e r
16 \ rhead { S e c t i o n \ t h e s e c t i o n }
17 \ l f o o t {V. Saxena and T . Mazumder}
18 \ r f o o t { Page \thepage} %r i g h t o f t h e f o o t e r
19
23 % ”\ t h e s e c t i o n ” i s a r e f e r e n c e t o t h e c o u n t e r t h a t k e e p s
t r a c k o f what s e c t i o n we ’ r e i n ! D i t t o f o r ”\ t h e p a g e ”
24
25 \renewcommand{\ f o o t r u l e w i d t h }{1 pt }
The above demo should help serve most of your purposes. Other two-sided
document classes use a slightly different approach. If you are particularly en-
thusiastic, we encourage you to read up on that here. It’s comprehensive.
You might have noticed that the fancy style doesn’t apply to the page with the
title and table of contents. Also, page numbering starts after that. Here’s what
we did:
1 \ maketitle
2 \ tableofcontents
3 \ thispagestyle {empty}
4 \ clearpage
5 \pagenumbering{ a r a b i c }
3.2 Footnotes
Suppose you are making a point in your document. The assertion needs a
clarifying remark, but making it immediately will take the focus away from the
actual story. Here’s where footnotes come in handy.1 .To maintain the readability
in the source code2 , consider this technique.
The current value of the footnote counter is at 2. You can refer to that footnote
again2 . Or to a previous justification1 .
Footnote indexing comes in various styles.
§
1 Here ’ s where f o o t n o t e s come i n handy . \ footnote {You s e e
them i n l e c t u r e s l i d e s a l l t h e time } . To m a i n t a i n t h e
r e a d a b i l i t y i n t h e s o u r c e code \footnotemark , c o n s i d e r
t hi s technique .
2
3 \ footnotetext {Your c o l l a b o r a t o r s a r e i m p o r t a n t ! }
4
5 The c u r r e n t v a l u e o f t h e f o o t n o t e c o u n t e r i s a t 2 . You
can r e f e r t o t h a t f o o t n o t e a g a i n \footnotemark [ \ value {
f o o t n o t e } ] . Or t o a p r e v i o u s j u s t i f i c a t i o n \
footnotemark [ 1 ] .
6
4 Indices
4.1 Introduction
You’ve definitely found yourself opening the last few pages of a textbook, and
you would’ve noticed a little handy something called the index . It contains a
list of all the keywords found in the book, and where to find those keywords in
the book. If you look at this document, you’ll find a similar section right at the
end.
8 \ begin{ document }
9 \ tableofcontents
10 %Other s e c t i o n s
11 \ section { I n d i c e s }
12 \ subsection { Introduction }
13 I f you have f i n d y o u r s e l f t h a t you opened t h e l a s t few
p a g e s o f a textbook , you ’ l l n o t i c e a l i t t l e handy
something c a l l e d t h e \ t e x t i t { i n d e x }\ index{ i n d e x } . I t
c o n t a i n s a l i s t o f a l l t h e keywords \index{ keywords }
found i n t h e book , and where t o f i n d t h o s e keywords i n
t h e book . I f you l o o k a t t h i s document \index{ document
} , you ’ l l f i n d a s i m i l a r s e c t i o n \index{ s e c t i o n } r i g h t
a t t h e end .
14 \ subsection { Basic I n d i c es }
15 To i n s e r t an i n d e x s e c t i o n \index{ s e c t i o n } i n t o your
document , you do not have t o do a n y t h i n g manually .
Once a g a i n \LaTeX{}\ index {\LaTeX} p a c k a g e s \index{
package } have g o t you c o v e r e d !
16
easily .
18
19 %Rest o f t h e document
20 \ printindex
21
22 \end{ document }
values to \makeindex:
1 \makeindex [ columns =1, t i t l e =Document Index ]
In this example the index is presented in a three-column format with the pa-
rameter columns=1, and the title is changed to “Document Index” by the
title=Alphabetical Index parameter; these parameters are passed to \makeindex
in the preamble. See the reference guide for a list of available parameters and
their description.
The index generated looks like:
5 Multiple Columns
5.1 Introduction
Have you ever seen newspaper articles where the content is divided into two
or more columns? You can do that in LATEX too. Just pass in the parameter
\twocolumn in the \documentclass{} command, like
\documentclass[twocolumn]{article}
The render looks like this:
5.2 Multicol
Lorem ipsum dolor sit stique senectus et netus trices bibendum. Ae-
amet, consectetuer adi- et malesuada fames ac nean faucibus. Morbi do-
piscing elit. Ut purus turpis egestas. Mauris lor nulla, malesuada eu,
elit, vestibulum ut, pla- ut leo. Cras viverra me- pulvinar at, mollis ac,
cerat ac, adipiscing vi- tus rhoncus sem. Nulla nulla. Curabitur auctor
tae, felis. Curabitur et lectus vestibulum urna semper nulla. Donec va-
dictum gravida mauris. fringilla ultrices. Pha- rius orci eget risus. Duis
Nam arcu libero, no- sellus eu tellus sit amet nibh mi, congue eu, ac-
nummy eget, consecte- tortor gravida placerat. cumsan eleifend, sagittis
tuer id, vulputate a, ma- Integer sapien est, iacu- quis, diam. Duis eget
gna. Donec vehicula au- lis in, pretium quis, vi- orci sit amet orci dignis-
gue eu neque. Pellentes- verra ac, nunc. Prae- sim rutrum.
que habitant morbi tri- sent eget sem vel leo ul-
5 \ begin{ m u l t i c o l s }{3}
6 [
7 \ section { F i r s t S e c t i o n }
8 The f o l l o w i n g t e x t has columns s e p a r a t e d by r u l e r s
9 ]
10 \ lipsum [ 1 ]
11 \end{ m u l t i c o l s }
As you see, the column separator can be set to a specific colour also. Below a
description of each command:
\setlength{\columnseprule}{1pt} This determines the width of the
ruler to be used as column separator; it’s set to 0 by default. In the
example, a column whose width is 1pt is printed.
\def\columnseprulecolor{\color{blue}} The colour of the separator
ruler can be set to any color you want.
index, 7
section, 7
keywords, 7
14