1 LaTeX |
1 LaTeX |
2 ===== |
2 ===== |
3 |
3 |
4 Introduction |
4 Introduction |
5 ------------ |
5 ------------ |
6 LaTeX is a typesetting program used to produce excellently typeset documents. It is extensively used for producing high quality scientific and mathematical documents. It may also be used for producing other kinds of documents, ranging from simple one page articles or letters |
6 LaTeX is a typesetting program that produces excellently typeset documents. Typesetting is placing text onto a page with all the style formatting defined, so that content looks as intended. It is extensively used for producing high quality scientific and mathematical documents. It is also used for producing other kinds of documents, ranging from simple one page articles or letters to books. LaTeX is based on the TeX typesetting language. |
7 |
|
8 |
|
9 TeX & LaTeX |
|
10 ~~~~~~~~~~~ |
|
11 |
7 |
12 TeX |
8 TeX |
13 +++ |
9 ~~~ |
14 |
10 |
15 TeX is a typesetting system designed by Donald Knuth, the renowned Computer Scientist and Emeritus professor at Stanford University. Typesetting is placing text onto a page with all the style formatting defined, so that content looks as intended. |
11 TeX is a typesetting system designed and developed by Donald E. Knuth, the renowned Computer Scientist and Emeritus professor at Stanford University. |
16 |
12 |
17 It was designed with two goals in mind- |
13 It was designed with two goals in mind- |
18 |
14 |
19 1. To allow anybody to produce high-quality books using a reasonable amount of effort. |
15 1. To allow anybody to produce high-quality books using a reasonable amount of effort. |
20 2. To provide a system that would give the exact same results on all computers, now and in the future |
16 2. To provide a system that would give the exact same results on all computers, now and in the future |
21 |
17 |
22 TeX is well known for it's stability and portability. |
18 TeX is well known for it's stability and portability. TeX is known to be virtually bug free. |
23 |
|
24 TeX is pronounced as "tech". |
|
25 |
19 |
26 The current version of TeX is 3.1415926 and is converging to π. |
20 The current version of TeX is 3.1415926 and is converging to π. |
27 |
21 |
28 LaTeX |
22 LaTeX |
29 +++++ |
23 ~~~~~ |
30 |
24 |
31 LaTeX was originally written by Leslie Lamport in the early 1980s. It is an extension of TeX, consisting of TeX macros and a program to parse the LaTeX files. It is easier to use than TeX itself, at the same time producing the same quality of output. |
25 LaTeX is an extension of TeX, consisting of TeX macros and a program to parse the LaTeX files. It is supposed to be an easier to use language than TeX, but producing the same quality of output. It was developed by Leslie Lamport in the early 1980s and is now being maintained and developed by the LaTeX3 Project. |
32 |
26 |
33 LaTeX is pronounced either as "Lah-tech" or "Lay-tech" |
27 LaTeX is pronounced either as "Lah-tech" or "Lay-tech" |
34 |
28 |
35 WYSIWG vs. WYSIWM |
29 Why should you use it? |
36 ~~~~~~~~~~~~~~~~~ |
30 ~~~~~~~~~~~~~~~~~~~~~~ |
37 |
31 |
38 WYSIWG is an acronym for "What You See Is What You Get". Word processors, are typically WYSIWG tools. LaTeX, TeX or other TeX based tools are not. They are typesetting or text formatting or document description programs. They can be called WYSIWM or "What You See Is What you Mean" systems, since you give a description of how things look, and LaTeX typesets the document for you. |
32 A few reasons for using LaTeX - |
39 |
33 |
40 Here are a few reasons, why you should use LaTeX - |
34 * It produces documents with excellent visual quality. |
41 |
35 * It does the typesetting for you, leaving you - the author - to focus on writing the content. |
42 * LaTeX produces documents with excellent visual quality, especially mathematical and scientific documents. |
36 * It makes writing math just as easy as writing simple text. |
43 * It does the typesetting to you. Typically, when one works with a word-processor, the user is doing the text formatting or typesetting along with typing out the content. LaTeX allows the user to concentrate on the content leaving aside the typesetting to LaTeX. |
37 * It's renowned for it's stability and a virtually bug free code base. |
44 * It is light on your resources as compared to most of the word processors available today. |
38 * It is light on your resources as compared to most of the word processors available today. |
45 * It is well known for it's stability and for it's virtually bug free code base. |
39 * It uses plain text files as input and can give output in a variety of formats including PDFs and html making it platform independent. |
46 * It encourages users to structure documents by meaning rather than appearance, thereby helping produce well structured documents. |
|
47 * It uses plain text files as input, which have a lot of well known advantages over binary files. To state a few, they can be opened with any editor on any operating system, they are smaller in size compared to the binaries, can be version controlled and can be processed using widely used text processing utilities. |
|
48 * The output can be generated in more than one formats. |
|
49 * It is free software (free as in freedom) and gratis too. |
40 * It is free software (free as in freedom) and gratis too. |
50 * It is widely used. |
41 * It is widely used and has a large user community. |
51 |
42 |
52 Hello World |
43 First Document |
53 ~~~~~~~~~~~ |
44 -------------- |
54 |
45 |
55 OK, let's get started with our first LaTeX document. Open up your favorite editor and type in the following code. |
46 Let's begin by writing a simple LaTeX, Hello World, document. The following code is typed out into a text editor. |
56 |
47 |
57 :: |
48 :: |
58 |
49 |
59 %hello.tex - First LaTeX document |
50 %hello.tex - The Hello World of LaTeX |
60 \documentclass{article} |
51 \documentclass{article} |
61 |
52 |
62 \begin{document} |
53 \begin{document} |
63 Hello, World! |
54 Hello, World! |
64 \end{document} |
55 \end{document} |
65 |
56 |
66 Save the file as ``hello.tex`` and open up a terminal to compile your ``tex`` file to get the output in a ``pdf`` format. |
57 Save the file as ``hello.tex`` and open up a terminal to compile your ``tex`` file to get the output in a ``pdf`` format. |
67 |
58 |
68 Compiling & Output |
59 Compiling & Output |
69 ++++++++++++++++++ |
60 ~~~~~~~~~~~~~~~~~~ |
70 |
61 |
71 :: |
62 :: |
72 |
63 |
73 $pdflatex hello.tex |
64 $pdflatex hello.tex |
74 |
65 |
75 Output written on hello.pdf (1 page, 5733 bytes). |
66 Output written on hello.pdf (1 page, 5733 bytes). |
76 Transcript written on hello.log. |
67 Transcript written on hello.log. |
77 |
68 |
78 Open the ``hello.pdf`` to see the output as shown. |
69 Open the ``hello.pdf`` to see the output as shown. |
79 |
70 |
80 .. image:: examples/hello.jpg |
|
81 |
|
82 Note: The command ``latex`` is often used to get the ``dvi`` output. But, throughout this course, we shall use pdflatex to compile our documents. |
71 Note: The command ``latex`` is often used to get the ``dvi`` output. But, throughout this course, we shall use pdflatex to compile our documents. |
83 |
72 |
84 A peek at the source |
73 What does it mean? - Understanding the source |
85 ++++++++++++++++++++ |
74 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
86 |
75 |
87 ``%hello.tex - First LaTeX document`` |
76 ``%hello.tex - First LaTeX document`` |
88 |
77 |
89 This line is a comment. LaTeX ignores this line and it is meant only for the human readers. LaTeX ignores anything after a ``%`` symbol to the end of the line. |
78 The first line is a comment. It is meant only for human readers and LaTeX simply ignores that line. Anything following a ``%`` symbol, until the end of the line, is ignored by LaTeX. |
90 |
79 |
91 ``\documentclass{article}`` |
80 ``\documentclass{article}`` |
92 |
81 |
93 This line is a command and sets the ``documentclass`` of the document to ``article``. LaTeX has other classes like ``report``, ``book``, ``letter``, etc. The typesetting of the document varies depending on the ``documentclass`` of the document. |
82 This line is a command and sets the ``documentclass`` of the document to ``article``. LaTeX has other classes like ``report``, ``book``, ``letter``, etc. The typesetting of the document varies, depending on the ``documentclass`` of the document. |
94 |
83 |
95 |
84 |
96 ``\begin{document}`` |
85 ``\begin{document}`` |
97 |
86 |
98 This line informs LaTeX that this is the beginning of the content of the document. |
87 This line informs LaTeX that this is the beginning of the content of the document. The command, technically speaking, marks the beginning of the ``document`` environment. |
99 |
88 |
100 ``Hello, World!`` |
89 ``Hello, World!`` |
101 |
90 |
102 This is the actual text displayed in the document. |
91 This is the actual text displayed in the document. |
103 |
92 |
104 ``\end{document}`` |
93 ``\end{document}`` |
105 |
94 |
106 This line tells LaTeX that the document is complete and LaTeX will simply ignore anything written after this line. |
95 The end command marks the end of the ``document`` environment. It tells LaTeX that the document is complete and LaTeX will simply ignore anything written after this line. |
107 |
|
108 Where do we want to go |
|
109 ~~~~~~~~~~~~~~~~~~~~~~ |
|
110 |
|
111 During the course of this session we will learn how to do various things in LaTeX and try to produce the sample document provided. |
|
112 |
96 |
113 Some Basics |
97 Some Basics |
114 ~~~~~~~~~~~ |
98 ~~~~~~~~~~~ |
115 Before we get started with creating the document, let's try to understand a few things that would be useful during the course of this session. |
|
116 |
|
117 Spaces |
|
118 ++++++ |
|
119 |
99 |
120 LaTeX treats multiple empty spaces (or lines) as a single space (or line). An empty line between two lines of text is considered as a change of paragraphs. |
100 LaTeX treats multiple empty spaces (or lines) as a single space (or line). An empty line between two lines of text is considered as a change of paragraphs. |
121 |
101 |
122 Line & Page Breaks |
102 In order to explicitly instruct LaTeX to start a new-line, ``\\`` or ``\newline`` command is used. Appending ``*`` to ``\\``, instructs LaTeX to create a new line, without creating a new page at that point. |
123 ++++++++++++++++++ |
103 |
124 |
104 As already mentioned, ``%`` symbol marks the beginning of a comment. How would we then use it in our document's text? ``%`` is one of the many special characters and is used by escaping it with a backslash, as shown. Other special characters are ``~ # $ ^ & _ { } \``. All of them, except the backslash character, can be inserted in the document by escaping them with a ``\`` character. To insert the ``\`` character, ``\textbackslash`` must be used. |
125 LaTeX usually does the job of breaking up your content into lines and pages, and does it well. But under some circumstances, you might want to instruct LaTeX to break line or start a new page at a particular point. |
105 |
126 |
106 :: |
127 ``\\`` or ``\newline`` command is used to create a new line at the point where the command is issued. |
107 |
128 Appending ``*`` to ``\\``, instructs LaTeX to create a new line, without creating a new page at that point. |
108 %hello.tex - First LaTeX document |
129 |
109 \documentclass{article} |
130 Paragraphs |
110 \begin{document} |
131 ++++++++++ |
111 Hello, World! |
132 |
112 This will not start a new line. |
133 As already mentioned, LaTeX considers an empty line between two lines of text as a new paragraph. ``\par`` command may also be used to start a newline. It is equivalent to the blank line. |
113 |
134 |
114 But, this will start a new paragraph. |
135 By default LaTeX indents new paragraphs. If you do not wish to have the paragraph indented, you can use the ``\nointend`` command at the beginning of the paragraph. |
115 Again no new line. \% what follows isn't a comment. |
136 |
116 \end{document} |
137 Special Characters |
117 This is text that is ignored. |
138 ++++++++++++++++++ |
118 |
139 |
119 Basic Structure |
140 LaTeX associates special meaning to the characters ``~ # $ % ^ & _ { } \``. |
120 --------------- |
141 |
|
142 To have these characters in the text of your document, you need to prefix a backslash to them. ``\~ \# \% \$ \^ \& \_ \{ \} \textbackslash`` |
|
143 |
|
144 |
|
145 Commands |
|
146 ++++++++ |
|
147 |
|
148 * All LaTeX commands start with a backslash ``\``. |
|
149 * Like the commands in Linux, they are case sensitive. |
|
150 * They usually have a backslash followed by a consisting of letters only. Any character other than letters, like space, numbers or special characters terminate the command. |
|
151 * The commands for producing special characters in the text, is an exception. They contain a backslash followed by a single special character. |
|
152 * Commands may have parameters, which are supplied to them by enclosing them in curly braces ``{ }``. |
|
153 * They may also have a few optional parameters which are added after the name in square brackets ``[ ]``. |
|
154 |
|
155 |
|
156 Environments |
|
157 ++++++++++++ |
|
158 |
|
159 Environments are very similar to the commands, except that they effect larger parts of the document. For example, we used the ``document`` environment in our first LaTeX document. |
|
160 |
|
161 * They begin with a ``\begin`` and end with a ``\end`` |
|
162 * In general environments can be nested within each other. |
|
163 |
|
164 Some Structural Elements |
|
165 ------------------------ |
|
166 |
121 |
167 ``\documentclass`` |
122 ``\documentclass`` |
168 ~~~~~~~~~~~~~~~~~~ |
123 ~~~~~~~~~~~~~~~~~~ |
169 As already stated, the ``documentclass`` command tells LaTeX, the type of the document that you intend to create. Each class has a few differences in how the content of the document is typeset. We presently have it set to the article class. Let us try changing it to the report class. |
124 As already stated, the ``documentclass`` command tells LaTeX, the type of the document that you intend to create. Each class has a few differences in how the content of the document is typeset. |
170 |
125 |
171 Note that the top matter of the document appears in a different page for the report class. |
126 Some of the available LaTeX classes are, article, proc, report, book, slides, letter. |
172 |
|
173 Some of the LaTeX classes that you may want to use are, article, proc, report, book, slides, letter. |
|
174 |
127 |
175 The ``documentclass`` command also accepts a few optional parameters. For example:: |
128 The ``documentclass`` command also accepts a few optional parameters. For example:: |
176 \documentclass[12pt,a4paper,oneside,draft]{report} |
129 \documentclass[12pt,a4paper,oneside,draft]{report} |
177 |
130 |
178 ``12pt`` specifies the size of the main font in the document. The relative sizes of the various fonts is maintained, when the font size is changed. If no size is specified, ``10pt`` is assumed by default. |
131 ``12pt`` specifies the size of the main font in the document. The relative sizes of the various fonts is maintained, when the font size is changed. If no size is specified, ``10pt`` is assumed by default. |
184 ``draft`` marks the hyphenation and justification problems in the document with a small square in the right hand margin of the document, so that they can be easily spotted. |
137 ``draft`` marks the hyphenation and justification problems in the document with a small square in the right hand margin of the document, so that they can be easily spotted. |
185 |
138 |
186 Note: Everything written in between the ``\documentclass`` command and the ``\begin{document}`` command is called the Preamble. |
139 Note: Everything written in between the ``\documentclass`` command and the ``\begin{document}`` command is called the Preamble. |
187 |
140 |
188 |
141 |
189 Parts, Chapters and Sections |
|
190 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
191 |
|
192 Often documents are divided into various parts, chapters, sections and subsections. LaTeX provides an intuitive mechanism to include this in your documents. It has various commands like ``part``, ``chapter``, ``section``, ``subsection``, ``subsubsection``, ``paragraph`` and ``subparagraph``. Note that all these commands are not available in all the document classes. The ``chapter`` command is available only in books and reports. Also, the ``letter`` document class does not have any of these commands. |
|
193 |
|
194 Let us now give our document some structure, using these commands. |
|
195 |
|
196 Note that you do not need to provide any numbers to the commands. LaTeX automatically takes care of the numbering. |
|
197 Also, you do not need to enclose the text of a block within ``\begin`` and ``\end`` commands. LaTeX starts a new block each time it finds a sectioning command. |
|
198 :: |
|
199 |
|
200 \section[Short Title]{This is a very long title and the Short Title will appear in the Table of Contents.} |
|
201 |
|
202 |
|
203 Section Numbering |
|
204 +++++++++++++++++ |
|
205 |
|
206 As already, you don't need to explicitly do any numbering in LaTeX. Parts are numbered using roman numerals; Chapters and sections are numbered using decimal numbers. When the table of contents is inserted into a document, all the numbered headings automatically appear in it. |
|
207 |
|
208 By default LaTeX has numbering up 2 levels, i.e, the parts, chapters, sections and subsections are numbered. You can change this by setting the ``secnumdepth`` counter using the ``\setcounter`` command. The following command removes numbering of the subsections. Only parts, chapters and sections are numbered. |
|
209 :: |
|
210 |
|
211 \setcounter{secnumdepth}{1} |
|
212 |
|
213 A sectioning command appended with an asterisk gives an unnumbered heading that is not included in the table of contents. |
|
214 :: |
|
215 |
|
216 \section*{Introduction} |
|
217 |
|
218 Top Matter |
142 Top Matter |
219 ~~~~~~~~~~ |
143 ~~~~~~~~~~ |
220 |
144 |
221 The information about the document such as it's title, the date, the author(s) information etc, is collectively known as the topmatter. Though there is no command called ``topmatter``, the term topmatter is frequently used in LaTeX documentation. |
145 The information about the document such as it's title, the date, the author(s) information etc, is collectively known as the topmatter. The term topmatter is frequently used in LaTeX documentation. |
222 |
146 |
223 Let us input the top matter for our document now. |
147 Let us add top matter to our document, now. |
224 :: |
148 :: |
225 |
149 |
226 \title{LaTeX - A How-to} |
150 \title{LaTeX - A How-to} |
227 \author{The FOSSEE Team} |
151 \author{The FOSSEE Team} |
228 \date |
152 \date |
229 |
153 |
230 The commands ``\title`` and ``\author`` are self explanatory. |
154 The commands ``\title`` and ``\author`` are self explanatory. |
231 The ``\date`` command automatically puts in today's date into the document. Now let us compile and look at the result. |
155 The ``\date`` command automatically puts in today's date into the document. Now let us compile and look at the result. |
232 |
156 |
233 You would observe that the details do not appear in the document after recompilation. This is because, LaTeX has not been instructed what to do with the top matter information that you have given it. Use the ``\maketitle`` command within the document environment to instruct LaTeX to place the top matter information into the document. |
157 To put a specific date, you can specify it as below |
|
158 |
|
159 :: |
|
160 |
|
161 \date{June 1, 2010} |
|
162 |
|
163 These details do not appear in the document until we use the ``\maketitle`` command with the document environment to instruct LaTeX to place the top matter information into the document. |
|
164 |
|
165 Sectioning Commands |
|
166 ~~~~~~~~~~~~~~~~~~~ |
|
167 |
|
168 Documents are often divided into parts, chapters, sections and subsections. LaTeX provides an intuitive mechanism to use them in your documents. |
|
169 |
|
170 +-------------------+-------+------------------------+ |
|
171 | command | level | comments | |
|
172 +-------------------+-------+------------------------+ |
|
173 | ``part`` | -1 | not in letters | |
|
174 +-------------------+-------+------------------------+ |
|
175 | ``chapter`` | 0 | only books and reports | |
|
176 +-------------------+-------+------------------------+ |
|
177 | ``section`` | 1 | not in letters | |
|
178 +-------------------+-------+------------------------+ |
|
179 | ``subsection`` | 2 | not in letters | |
|
180 +-------------------+-------+------------------------+ |
|
181 | ``subsubsection`` | 3 | not in letters | |
|
182 +-------------------+-------+------------------------+ |
|
183 | ``paragraph`` | 4 | not in letters | |
|
184 +-------------------+-------+------------------------+ |
|
185 | ``subparagraph`` | 5 | not in letters | |
|
186 +-------------------+-------+------------------------+ |
|
187 |
|
188 LaTeX has seven levels of sectioning commands, as shown above. |
|
189 |
|
190 Text of a block or a section of the document need not be enclosed within ``\begin`` and ``\end`` commands. LaTeX starts a new block each time it finds a sectioning command. |
|
191 :: |
|
192 |
|
193 \section[Short Title]{This is a very long title and the Short Title will appear in the Table of Contents.} |
|
194 |
|
195 The short title appears in the table of contents, if at all one is generated. |
|
196 |
|
197 Section Numbering |
|
198 +++++++++++++++++ |
|
199 |
|
200 As you may have observed, numbering is done automatically in LaTeX. Parts are numbered using roman numerals; Chapters and sections are numbered using decimal numbers. When a table of contents is inserted into the document, all the numbered headings automatically appear in it. |
|
201 |
|
202 A sectioning command appended with an asterisk gives an unnumbered heading that is not included in the table of contents. |
|
203 :: |
|
204 |
|
205 \section*{Introduction} |
|
206 |
|
207 By default, levels up to 2, are numbered, i.e, parts, chapters, sections and subsections. This can be changed by setting the ``secnumdepth`` counter using the ``\setcounter`` command. The following command removes numbering of the subsections. Only parts, chapters and sections will be numbered. |
|
208 :: |
|
209 |
|
210 \setcounter{secnumdepth}{1} |
|
211 |
|
212 |
|
213 Appendices |
|
214 ~~~~~~~~~~ |
|
215 |
|
216 LaTeX allows for separate numbering for appendices. ``\appendix`` command indicates that the sections following it, are to be included in the appendix. |
|
217 :: |
|
218 |
|
219 \appendix |
|
220 \chapter{First Appendix} |
234 |
221 |
235 Abstract |
222 Abstract |
236 ~~~~~~~~ |
223 ~~~~~~~~ |
237 Lets now place and abstract in the document using the ``abstract`` environment of LaTeX. The abstract appears in the document after the topmatter but before the main body of the document. |
224 LaTeX provides an ``abstract`` environment, to place an abstract in a document. The abstract appears in the document after the topmatter but before the main body of the document. |
238 :: |
225 :: |
239 |
226 |
240 \begin{abstract} |
227 \begin{abstract} |
241 The abstract abstract. |
228 The abstract abstract. |
242 \end{abstract} |
229 \end{abstract} |
243 |
230 |
244 |
231 By default LaTeX uses the word "Abstract" as a title for the abstract. This can be changed using the ``\renewcommand``. |
245 Appendices |
232 :: |
246 ~~~~~~~~~~ |
233 |
247 |
234 \renewcommand{\abstractname}{Summary} |
248 LaTeX allows for separate numbering for appendices. ``\appendix`` command indicates that the sections following are to be included in the appendix. |
235 |
249 :: |
236 |
250 |
|
251 \appendix |
|
252 \chapter{First Appendix} |
|
253 |
237 |
254 Table of Contents |
238 Table of Contents |
255 ~~~~~~~~~~~~~~~~~ |
239 ~~~~~~~~~~~~~~~~~ |
256 |
240 |
257 Parts, chapters or sections that have been auto numbered by LaTeX automatically appear in the Table of Contents (ToC). ``\tableofcontents`` command places a the ToC, where the command has been issued. |
241 Parts, chapters or sections that have been auto numbered by LaTeX automatically appear in the Table of Contents (ToC). ``\tableofcontents`` command places the ToC at the location, where the command has been issued. |
258 |
242 |
259 The counter ``tocdepth`` specifies the depth up to which headings appear in the ToC. It can be set using the ``\setcounter`` command as shown below. |
243 The counter ``tocdepth`` specifies the depth up to which headings appear in the ToC. It can be set using the ``\setcounter`` command as shown below. |
260 :: |
244 :: |
261 |
245 |
262 \setcounter{tocdepth}{3} |
246 \setcounter{tocdepth}{3} |
263 |
247 |
264 Unnumbered sections can be placed in the table of contents using the ``\addcontentsline`` command as shown below. |
248 Unnumbered sections can be placed in the table of contents using the ``\addcontentsline`` command as shown below. |
265 :: |
249 :: |
266 |
250 |
267 \section*{Introduction} |
251 \section*{Preface} |
268 \addcontentsline{toc}{section}{Introduction} |
252 \addcontentsline{toc}{section}{Preface} |
269 |
253 |
270 Note: To get the correct entries in your table of contents, you will need to run one extra compilation, each time. This is because, the entries of the table of contents are collected during each compilation of the document and utilized during the next compilation. |
254 Note: To get the correct entries in your table of contents, you will need to run one extra compilation, each time. This is because, the entries of the table of contents are collected during each compilation of the document and utilized during the next compilation. |
271 |
255 |
272 Elementary Text Typesetting |
256 Typesetting Text |
273 --------------------------- |
257 ---------------- |
274 |
258 |
275 Emphasizing |
259 Text formatting |
276 ~~~~~~~~~~~ |
260 ~~~~~~~~~~~~~~~ |
277 |
261 |
278 *Italic* font is generally used to emphasize text. The ``\emph`` command may be used to achieve this effect in LaTeX. |
262 Font Styles and Size |
279 :: |
263 ++++++++++++++++++++ |
280 |
264 |
281 This is the \emph{emphasized text}. |
265 LaTeX has three font families: |
282 |
266 |
283 If the ``\emph`` command is nested within another emphasize command, LaTeX emphasized that text using normal fonts. |
267 1. roman ``\textrm{your text here}`` |
284 :: |
268 2. serif ``\textsf{your text here}`` |
285 |
269 3. monospace ``\texttt{your text here}`` |
286 \emph{Did you wonder what happens when we try \emph{emphasizing text} within \emph{emphasized text}}? |
270 |
287 |
271 For emphasizing text, *italics* are generally used. The ``\emph`` command is used to emphasize text. |
288 *This is emphasized text, and* this is emphasized text with normal font *, within* emphasized text. |
272 ``\textbf`` gives **bold face** text. Underlines can be made using the ``\uline`` command and ``\sout`` strikes out text. For small caps, ``\textsc`` command is to be used. |
|
273 |
|
274 LaTeX provides a series of commands to change the size of text. The table below shows the commands and the size of text, they produce. |
|
275 |
|
276 +-------------------+----------------+-------------+-------------+ |
|
277 | size | 10pt (default) | 11pt option | 12pt option | |
|
278 +===================+================+=============+=============+ |
|
279 | ``\tiny`` | 5pt | 6pt | 6pt | |
|
280 +-------------------+----------------+-------------+-------------+ |
|
281 | ``\scriptsize`` | 7pt | 8pt | 8pt | |
|
282 +-------------------+----------------+-------------+-------------+ |
|
283 | ``\footnotesize`` | 8pt | 9pt | 10pt | |
|
284 +-------------------+----------------+-------------+-------------+ |
|
285 | ``\small`` | 9pt | 10pt | 11pt | |
|
286 +-------------------+----------------+-------------+-------------+ |
|
287 | ``\normalsize`` | 10pt | 11pt | 12pt | |
|
288 +-------------------+----------------+-------------+-------------+ |
|
289 | ``\large`` | 12pt | 12pt | 14pt | |
|
290 +-------------------+----------------+-------------+-------------+ |
|
291 | ``\Large`` | 14pt | 14pt | 17pt | |
|
292 +-------------------+----------------+-------------+-------------+ |
|
293 | ``\LARGE`` | 17pt | 17pt | 20pt | |
|
294 +-------------------+----------------+-------------+-------------+ |
|
295 | ``\huge`` | 20pt | 20pt | 25pt | |
|
296 +-------------------+----------------+-------------+-------------+ |
|
297 | ``\Huge`` | 25pt | 25pt | 25pt | |
|
298 +-------------------+----------------+-------------+-------------+ |
|
299 |
|
300 |
|
301 Superscript and Subscript |
|
302 +++++++++++++++++++++++++ |
|
303 |
|
304 For superscripting text in the text mode, LaTeX provides the ``\textsuperscript`` command. |
|
305 :: |
|
306 |
|
307 This is how you super\textsuperscript{script} text. |
|
308 |
|
309 LaTeX does not provide any command for subscripting text in the text mode. The math mode needs to be used to obtain subscripts. |
|
310 |
|
311 :: |
|
312 |
|
313 This is sub_{script} |
289 |
314 |
290 Quotation Marks |
315 Quotation Marks |
291 ~~~~~~~~~~~~~~~ |
316 +++++++++++++++ |
292 |
317 |
293 When typing in LaTeX, the double quotation mark ``"`` character shouldn't be used. The grave accent ````` character produces the left quote and the apostrophe ``'`` character produces the right quote. To obtain double quotes they are, each, used twice. |
318 When typing in LaTeX, the double quotation mark ``"`` character shouldn't be used. The grave accent ````` character produces the left quote and the apostrophe ``'`` character produces the right quote. To obtain double quotes they are, each, used twice. |
294 :: |
319 :: |
295 |
320 |
296 `` Here is an example of putting `text' in quotes '' |
321 `` Here is an example of putting `text' in quotes '' |
297 |
322 |
298 Dashes and Hyphens |
323 Dashes and Hyphens |
299 ~~~~~~~~~~~~~~~~~~ |
324 ++++++++++++++++++ |
300 |
325 |
301 LaTeX has four dashes of different lengths. Three of them can be produces with different number of consecutive dashes. The short dashes are used for hyphens, slightly longer ones for number ranges and the longest ones for comments. The fourth one is a mathematical symbol, the minus sign. |
326 LaTeX has four dashes of different lengths. Three of them can be produces with different number of consecutive dashes. The short dashes are used for hyphens, slightly longer ones for number ranges and the longest ones for comments. The fourth one is a mathematical symbol, the minus sign. |
302 :: |
327 :: |
303 |
328 |
304 The names of these dashes are: `-' hyphen, `--' en-dash, `---' em-dash and `$-$' minus sign. |
329 The names of these dashes are: `-' hyphen, `--' en-dash, `---' em-dash and `$-$' minus sign. |
305 |
330 |
306 The names for these dashes are: ‘‐’ hyphen, ‘–’ en-dash, ‘—’ em-dash and ‘−’ minus sign. |
331 The names for these dashes are: ‘‐’ hyphen, ‘–’ en-dash, ‘—’ em-dash and ‘−’ minus sign. |
307 |
332 |
308 Footnotes |
333 Lists - Itemize, Enumerate, and Description |
309 ~~~~~~~~~ |
334 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
310 |
|
311 With the command:: |
|
312 |
|
313 \footnote{footnote text} |
|
314 |
|
315 a footnote is printed at the foot of the current page. Footnotes should always be put after the word or sentence they refer to. Footnotes referring to a sentence or part of it should therefore be put after the comma or period. |
|
316 |
|
317 Note: Look at the ``\marginpar`` command to insert margin notes |
|
318 |
|
319 Flushleft, Flushright, and Center |
|
320 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
321 |
|
322 The environments ``flushleft`` and ``flushright`` generate paragraphs that are either left- or right-aligned. |
|
323 |
|
324 The ``center`` environment generates centered text. |
|
325 |
|
326 Itemize, Enumerate, and Description |
|
327 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
328 LaTeX has three different environments for producing lists. Itemize, Enumerate and Description allow you to produce lists of various types in LaTeX. |
335 LaTeX has three different environments for producing lists. Itemize, Enumerate and Description allow you to produce lists of various types in LaTeX. |
329 |
336 |
330 Itemize is used to produce unnumbered lists. The bullets of the list can be easily changed to use any character. Enumerate environment allows you to produce auto-numbered lists. The description environment, allows you to produce a list of definitions. These environments can be nested within each other, easily. |
337 Itemize is used to produce unnumbered lists. The bullets of the list can be easily changed to use any character. Enumerate environment allows you to produce auto-numbered lists. The description environment, allows you to produce a list of definitions. These environments can be nested within each other, easily. |
331 |
338 |
332 :: |
339 :: |
405 |
420 |
406 The verb command allows placing \verb|verbatim text| in-line. |
421 The verb command allows placing \verb|verbatim text| in-line. |
407 |
422 |
408 The | is just an example of a delimiter character. You can use any character except letters, * or space. |
423 The | is just an example of a delimiter character. You can use any character except letters, * or space. |
409 |
424 |
410 Tables, Figures and Captions |
425 Including Code |
411 ---------------------------- |
426 ++++++++++++++ |
412 |
427 |
413 The ``\tabular`` environment |
428 The ``listings`` package can be used to embed source code into your LaTeX document. We shall briefly explore inserting python code into our document. |
414 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
429 |
415 |
430 Obviously, you first need to tell LaTeX that you want it to use the ``listings`` package, using the ``\usepackage`` command. |
416 The ``tabular`` environment allows you to typeset tables in LaTeX. ``\begin{tabular}[pos]{col fmt}`` command can be used to specify the parameters of the table and start creating the table. |
431 :: |
417 |
432 |
418 The ``pos`` argument specifies the vertical position of the table relative to the baseline of the surrounding text. It can take on the values ``t`` for top, ``b`` for bottom, or ``c`` for center. |
433 \usepackage{listings} |
419 |
434 |
420 |
435 Then, we tell LaTeX that we are going to embed Python code into this document. A simple code highlighting for Python code can be achieved using this. |
421 The ``col fmt`` argument specifies the formatting of the columns of the table. You need to explicitly specify the formatting for each of the columns in the table. The ``col fmt`` argument can take on the following values. |
436 :: |
|
437 |
|
438 \lstset{language=Python, |
|
439 showstringspaces=false, |
|
440 } |
|
441 |
|
442 You might want to customize the code highlighting further using other variables like ``basicstyle``, ``commentstyle``, ``stringstyle``, ``keywordstyle`` etc. For detailed information on all this, you should look at the ``listings`` package documentation. |
|
443 |
|
444 You include a block of code into your document by enclosing it within the ``lstlisting`` environment. |
|
445 :: |
|
446 |
|
447 \begin{lstlisting} |
|
448 string="Hello, World! " |
|
449 for i in range(10): |
|
450 print string*i |
|
451 \end{lstlisting} |
|
452 |
|
453 You can also include source code files directly into your latex document, using the ``lstinputlisting`` command. |
|
454 :: |
|
455 |
|
456 \lstinputlisting[lastline=20]{lstexample.py} |
|
457 |
|
458 This command includes the first 20 lines of the file ``lstexample.py`` into out LaTeX document. |
|
459 |
|
460 Tables, Figures, Floats, & Referencing |
|
461 --------------------------------------------- |
|
462 |
|
463 Tables |
|
464 ~~~~~~ |
|
465 |
|
466 The ``tabular`` environment allows typesetting tables in LaTeX. Like any other environment it starts with ``\begin`` command and ends with ``\end``. |
|
467 |
|
468 It takes an optional argument, ``pos`` that specifies the vertical position of the table relative to the baseline of the surroundging text. It takes values of ``t`` for top, ``b`` for bottom, or ``c`` for center. |
|
469 |
|
470 The ``col fmt`` argument specifies the formatting of the columns of the table. Following are the possible arguments to the tabular environment. |
422 |
471 |
423 +---------------+------------------------------------+ |
472 +---------------+------------------------------------+ |
424 | ``l`` | left justified column content | |
473 | ``l`` | left justified column content | |
425 +---------------+------------------------------------+ |
474 +---------------+------------------------------------+ |
426 | ``r`` | right justified column content | |
475 | ``r`` | right justified column content | |
526 \includegraphics[scale=0.8, angle=30]{lion_orig.png} |
576 \includegraphics[scale=0.8, angle=30]{lion_orig.png} |
527 \end{figure} |
577 \end{figure} |
528 |
578 |
529 |
579 |
530 Captions |
580 Captions |
531 ~~~~~~~~ |
581 ++++++++ |
532 |
582 |
533 The ``\caption{text}`` command allows you to add captions to images or tables. LaTeX automatically numbers your tables and figures and you need not include numbers in the captions that you write. The caption appears below or on top of the image (or table), depending on whether you place it after or before the ``importgraphics`` (or ``tabular``) command. |
583 The ``\caption{text}`` command allows you to add captions to floats. Similar to section numbering, LaTeX automatically numbers floats too. The caption appears below or on top of the image (or table), depending on whether you place it after or before the ``importgraphics`` (or ``tabular``) command. |
534 |
584 |
535 :: |
585 :: |
|
586 |
536 \begin{figure}[h] |
587 \begin{figure}[h] |
537 \centering |
588 \centering |
538 \includegraphics[scale=0.8]{lion_orig.png} |
589 \includegraphics[scale=0.8]{lion_orig.png} |
539 \caption{CTAN lion drawing by Duane Bibby; thanks to www.ctan.org} |
590 \caption{CTAN lion drawing by Duane Bibby; thanks to www.ctan.org} |
540 \end{figure} |
591 \end{figure} |
541 |
592 |
542 The caption command also, like the section command, has the short caption optional parameter. The short caption will appear in the list of tables or figures. |
593 The caption command also, like the section command, has the short caption optional parameter. The short caption will appear in the list of tables or figures. |
543 |
594 |
544 List of Figures, Tables |
595 List of Figures, Tables |
545 ~~~~~~~~~~~~~~~~~~~~~~~ |
596 +++++++++++++++++++++++ |
546 |
597 |
547 LaTeX can automatically generate a List of Tables or Figures, with the table or figure numbers, the captions and page numbers on which they appear. This can be done using the ``\listoftables`` or ``listoffigures`` commands. |
598 LaTeX can automatically generate a List of Tables or Figures, with the table or figure numbers, the captions and page numbers on which they appear. They can be added to the document using the ``\listoftables`` or ``\listoffigures`` commands. |
548 |
599 |
549 Note: Just like table of contents, these lists also require an extra compilation. |
600 Note: Just like table of contents, these lists also require an extra compilation. |
550 |
601 |
551 Cross References |
602 Cross References |
552 ~~~~~~~~~~~~~~~~ |
603 ~~~~~~~~~~~~~~~~ |
553 |
604 |
554 LaTeX has a very efficient mechanism of inserting cross-references in documents. |
605 LaTeX has a very efficient mechanism of inserting cross-references in documents. |
555 |
606 |
556 The command ``\label{name}`` is used to label figures, tables or segments of text. ``\ref{name}`` refers to the object marked by the ``name`` by it's numbering (figure, table, section etc.) ``\pageref{name}`` gives the page number of the object which has been labeled with ``name``. |
607 The command ``\label{name}`` is used to label figures, tables or blocks of text, like chapters, sections etc. ``\ref{name}`` refers to the object marked by the ``name`` by it's numbering (figure, table, section etc.) ``\pageref{name}`` gives the page number of the object which has been labeled with ``name``. |
557 |
608 |
558 Note: Cross referencing also requires an extra compilation, like table of contents. |
609 Note: Cross referencing also requires an extra compilation, like table of contents. |
559 |
|
560 Bibliography |
|
561 ------------ |
|
562 |
|
563 Bibliography or references can be added to LaTeX documents in two ways - using the ``thebibliography`` environment, or using BibTeX. Let's first look at using the ``\thebibliography`` environment and then move on to BibTeX. |
|
564 |
|
565 ``thebibliography`` environment |
|
566 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
567 |
|
568 Writing bibliographies in LaTeX using the ``thebibliography`` environment is pretty easy. You simply have to list down all the bibliography items within the bibliography environment. |
|
569 |
|
570 Each entry of the bibliography begins with the command ``\bibitem[label]{name}``. The name is used to cite the bibliography item within the document using ``\cite{name}``. The label option replaces the numbers from the auto enumeration with the labels given. |
|
571 :: |
|
572 |
|
573 He used this lion in the illustrations for D Knuth's original TeXbook\cite{DKnuth}, for L Lamport's LaTeX book\cite{LLamport} |
|
574 |
|
575 \begin{thebibliography}{99} |
|
576 \bibitem{DKnuth} Donald E. Knuth (1984). \emph{The TeXbook} (Computers and Typesetting, Volume A). Reading, Massachusetts: Addison-Wesley. ISBN 0-201-13448-9. |
|
577 |
|
578 \bibitem{LLamport} Lamport, Leslie (1994). \emph{LaTeX: A document preparation system: User's guide and reference}. |
|
579 illustrations by Duane Bibby (2nd ed.). Reading, Mass: Addison-Wesley Professional. |
|
580 \end{thebibliography} |
|
581 |
|
582 The ``99`` in the example above indicates the maximum width of the label that the references may get. We here assume that the number of Bibliography items will be less than 100. If your document has less than 10 references, you may want to replace ``99`` with ``9``. |
|
583 |
|
584 BibTeX |
|
585 ~~~~~~ |
|
586 |
|
587 The previous section explained the process of listing references at the end of a document and embedding cross references. In this section let us explore the BibTeX environment for keeping track of references. |
|
588 |
|
589 Using BibTeX is a very convenient method to use, when writing multiple documents in a single area or field. BibTeX allows you to create a database of all your references and use them as and when required. |
|
590 |
|
591 The BibTeX database is stored in a ``.bib`` file. The structure of the file is quite simple and an example is shown below. |
|
592 :: |
|
593 |
|
594 @book{Lamport94, |
|
595 author = "Leslie Lamport", |
|
596 title = "A Document Preparation System: User's Guide and Reference", |
|
597 publisher = "Addison-Wesley Professional", |
|
598 year = "1994", |
|
599 edition = "second", |
|
600 note = "illustrations by Duane Bibby" |
|
601 } |
|
602 |
|
603 Each bibliography entry starts with a declaration of the type of the reference being mentioned. The reference is in the above example is of the book type. BibTeX has a wide range of reference types, for example, ``article, book, conference, manual, proceedings, unpublished``. |
|
604 |
|
605 The type of reference is followed by a left curly brace, and immediately followed by the citation key. The citation key, ``Lamport94`` in the example above is used to cite this reference using the command ``\cite{Lamport94}``. |
|
606 |
|
607 This is followed by the relevant fields and their values, listed one by one. Each entry must be followed by a comma to delimit one field from the other. |
|
608 |
|
609 To get your LaTeX document to use the bibliography database, you just add the following lines to your LaTeX document. |
|
610 :: |
|
611 |
|
612 \bibliographystyle{plain} |
|
613 \bibliography{LaTeX} |
|
614 |
|
615 Bibliography styles are files that tell BibTeX how to format the information stored in the ``.bib`` database file. The style file for this example is ``plain.bst``. Note that you do not need to add the ``.bst`` extension to the filename. If you wish to achieve a particular style of listing the bibliography items and citing them, you should use an appropriate style file. |
|
616 |
|
617 The ``bibliography`` command specifies the file that should be used as the database for references. The file used in this example is ``LaTeX.bib`` |
|
618 |
|
619 Compiling |
|
620 +++++++++ |
|
621 |
|
622 Adding BibTeX based references, slightly complicates the process of compiling the document to obtain the desired output. The exact workings of LaTeX and BibTeX will not be explained here. The procedure for obtaining the output (without any explanations) is as follows: |
|
623 |
|
624 1. Compile the ``.tex`` file using ``pdflatex`` - ``$pdflatex LaTeX(.tex)`` |
|
625 2. Compile the ``.bib`` file using ``bibtex`` - ``$bibtex LaTeX(.bib)`` |
|
626 3. Compile the ``.tex`` file again. |
|
627 4. Compile the ``.tex`` file for one last time! |
|
628 |
610 |
629 Typesetting Math |
611 Typesetting Math |
630 ---------------- |
612 ---------------- |
631 |
613 |
632 It is advisable to use the AMS-LaTeX bundle to typeset mathematics in LaTeX. It is a collection of packages and classes for mathematical typesetting. |
614 In general, it is advised to use the AMS-LaTeX bundle to typeset mathematics in LaTeX. AMS-LaTeX is a collection of packages and classes for mathematical typesetting. |
633 |
615 |
634 We load ``amsmath`` by issuing the ``\usepackage{amsmath}`` in the preamble. Through out this section, it is assumed that the ``amsmath`` package has been loaded. |
616 We load ``amsmath`` by issuing the ``\usepackage{amsmath}`` in the preamble. Through out this section, it is assumed that the ``amsmath`` package has been loaded. |
635 |
617 |
636 |
618 |
637 Math Mode |
619 Styles or Modes |
638 ~~~~~~~~~ |
620 ~~~~~~~~~~~~~~~ |
639 |
621 |
640 There are a few differences between the *math mode* and the *text mode*: |
622 LaTeX has two styles of inserting mathematical equations. They can either be inserted in-line within a paragraph (*text style*), or the paragraph can be broken to typeset them separately (*display style*). |
641 |
623 |
642 1. Most spaces and line breaks do not have any significance, as all spaces are either derived logically from the mathematical expressions, or have to be specified with special commands such as ``\``, ``\quad`` or ``\qquad`` |
624 Inline formulas are typeset by placing them in two ``$`` symbols or in between ``\(`` and ``\)``. |
643 |
625 |
644 2. Empty lines are not allowed. |
626 Displayed equations or equations that are set apart from the paragraph text are typeset by using ``\[`` and ``\]`` or ``\begin{equation*}`` and ``\end{equation*}`` for unnumbered equations or ``\begin{equation}`` and ``\end{equation}`` for numbered equations. |
645 |
627 |
646 3. Each letter is considered to be the name of a variable and will be typeset as such. If you want to typeset normal text within a formula, then you have to enter the text using the \text{...} command |
628 LaTeX provides several environments for handling equation groups and multi-line equations. ``multiline``, ``gather`` and ``align`` are a few. We shall look at ``align`` environment here. You could try out the others, in the lab. |
647 |
629 |
648 Single Equations |
630 ``align`` numbers each of the lines in the environment, and ``align*`` as expected, does not number any of them. The ``&`` is used to align the equations vertically and the ``\\`` command is used to break the lines. Line numbering can be skipped for a particular line in the ``align`` environment by placing a ``\nonumber`` before the line break. |
649 ~~~~~~~~~~~~~~~~ |
631 |
650 |
632 :: |
651 Mathematical equations can be inserted in-line within a paragraph (*text style*), or the paragraph can be broken to typeset it separately (*display style*). |
633 |
652 |
634 \begin{align} |
653 A mathematical equation within a paragraph is entered between ``$`` and ``$``. Larger equations are set apart from the paragraph, by enclosing them within ``\begin{equation}`` and ``\end{equation}``. If you don't wish to number a particular equation, the starred version of equation can be used. ``\begin{equation*}`` and ``\end{equation*}`` |
635 a^2 + b^2 &= c^2 \\ |
654 |
636 a + b &> c \nonumber\\ |
655 The equation can also be cross referenced using the ``\label`` and ``\eqref`` commands. |
637 b + c &> a \nonumber\\ |
|
638 c + a &> b \\ |
|
639 \end{align} |
656 |
640 |
657 Basic Elements |
641 Basic Elements |
658 ~~~~~~~~~~~~~~ |
642 ~~~~~~~~~~~~~~ |
659 |
643 |
660 Greek Letters can are entered as ``\alpha, \beta, \gamma, \delta, ...`` for lowercase letters and ``\Alpha, \Beta, \Gamma, ...`` for uppercase ones. |
644 Greek Letters can are entered as ``\alpha, \beta, \gamma, \delta, ...`` for lowercase letters and ``\Alpha, \Beta, \Gamma, ...`` for uppercase ones. |
727 4 & 5 & 6 \\ |
695 4 & 5 & 6 \\ |
728 7 & 8 & 9 |
696 7 & 8 & 9 |
729 \end{bmatrix} |
697 \end{bmatrix} |
730 \end{equation*} |
698 \end{equation*} |
731 |
699 |
732 Miscellaneous Stuff |
700 Spacing |
733 ------------------- |
701 ~~~~~~~ |
734 |
702 +---------+----------------+---------+ |
735 Presentations |
703 | Abbrev. | Spelled out | Example | |
736 ~~~~~~~~~~~~~ |
704 +---------+----------------+---------+ |
|
705 | | no space | | |
|
706 +---------+----------------+---------+ |
|
707 | \, | \thinspace | | |
|
708 +---------+----------------+---------+ |
|
709 | \: | \medspace | | |
|
710 +---------+----------------+---------+ |
|
711 | \; | \thickspace | | |
|
712 +---------+----------------+---------+ |
|
713 | | \quad | | |
|
714 +---------+----------------+---------+ |
|
715 | | \qquad | | |
|
716 +---------+----------------+---------+ |
|
717 | \! | \negthinspace | | |
|
718 +---------+----------------+---------+ |
|
719 | | \negmedspace | | |
|
720 +---------+----------------+---------+ |
|
721 | | \negthickspace | | |
|
722 +---------+----------------+---------+ |
|
723 |
|
724 |
|
725 |
|
726 Referencing |
|
727 ~~~~~~~~~~~ |
|
728 Equations can also be cross referenced using the ``\label`` and ``\eqref`` commands. |
|
729 |
|
730 |
|
731 Bibliography |
|
732 ------------ |
|
733 |
|
734 Bibliography or references can be added to LaTeX documents in two ways - using the ``thebibliography`` environment, or using BibTeX. Let's first look at using the ``\thebibliography`` environment and then move on to BibTeX. |
|
735 |
|
736 ``thebibliography`` environment |
|
737 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
738 |
|
739 Writing bibliographies in LaTeX using the ``thebibliography`` environment is pretty easy. You simply have to list down all the bibliography items within the bibliography environment. |
|
740 |
|
741 Each entry of the bibliography begins with the command ``\bibitem[label]{name}``. The name is used to cite the bibliography item within the document using ``\cite{name}``. The label option replaces the numbers from the auto enumeration with the labels given. |
|
742 :: |
|
743 |
|
744 He used this lion in the illustrations for D Knuth's original TeXbook\cite{DKnuth}, for L Lamport's LaTeX book\cite{LLamport} |
|
745 |
|
746 \begin{thebibliography}{99} |
|
747 \bibitem{DKnuth} Donald E. Knuth (1984). \emph{The TeXbook} (Computers and Typesetting, Volume A). Reading, Massachusetts: Addison-Wesley. ISBN 0-201-13448-9. |
|
748 |
|
749 \bibitem{LLamport} Lamport, Leslie (1994). \emph{LaTeX: A document preparation system: User's guide and reference}. |
|
750 illustrations by Duane Bibby (2nd ed.). Reading, Mass: Addison-Wesley Professional. |
|
751 \end{thebibliography} |
|
752 |
|
753 The ``99`` in the example above indicates the maximum width of the label that the references may get. We here assume that the number of Bibliography items will be less than 100. If your document has less than 10 references, you may want to replace ``99`` with ``9``. |
|
754 |
|
755 BibTeX |
|
756 ~~~~~~ |
|
757 |
|
758 The previous section explained the process of listing references at the end of a document and embedding cross references. In this section let us explore the BibTeX environment for keeping track of references. |
|
759 |
|
760 Using BibTeX is a very convenient method to use, when writing multiple documents in a single area or field. BibTeX allows you to create a database of all your references and use them as and when required. |
|
761 |
|
762 The BibTeX database is stored in a ``.bib`` file. The structure of the file is quite simple and an example is shown below. |
|
763 :: |
|
764 |
|
765 @book{Lamport94, |
|
766 author = "Leslie Lamport", |
|
767 title = "A Document Preparation System: User's Guide and Reference", |
|
768 publisher = "Addison-Wesley Professional", |
|
769 year = "1994", |
|
770 edition = "second", |
|
771 note = "illustrations by Duane Bibby" |
|
772 } |
|
773 |
|
774 Each bibliography entry starts with a declaration of the type of the reference being mentioned. The reference is in the above example is of the book type. BibTeX has a wide range of reference types, for example, ``article, book, conference, manual, proceedings, unpublished``. |
|
775 |
|
776 The type of reference is followed by a left curly brace, and immediately followed by the citation key. The citation key, ``Lamport94`` in the example above is used to cite this reference using the command ``\cite{Lamport94}``. |
|
777 |
|
778 This is followed by the relevant fields and their values, listed one by one. Each entry must be followed by a comma to delimit one field from the other. |
|
779 |
|
780 To get your LaTeX document to use the bibliography database, you just add the following lines to your LaTeX document. |
|
781 :: |
|
782 |
|
783 \bibliographystyle{plain} |
|
784 \bibliography{LaTeX} |
|
785 |
|
786 Bibliography styles are files that tell BibTeX how to format the information stored in the ``.bib`` database file. The style file for this example is ``plain.bst``. Note that you do not need to add the ``.bst`` extension to the filename. If you wish to achieve a particular style of listing the bibliography items and citing them, you should use an appropriate style file. |
|
787 |
|
788 The ``bibliography`` command specifies the file that should be used as the database for references. The file used in this example is ``LaTeX.bib`` |
|
789 |
|
790 Compiling |
|
791 +++++++++ |
|
792 |
|
793 Adding BibTeX based references, slightly complicates the process of compiling the document to obtain the desired output. The exact workings of LaTeX and BibTeX will not be explained here. The procedure for obtaining the output (without any explanations) is as follows: |
|
794 |
|
795 1. Compile the ``.tex`` file using ``pdflatex`` - ``$pdflatex LaTeX(.tex)`` |
|
796 2. Compile the ``.bib`` file using ``bibtex`` - ``$bibtex LaTeX(.bib)`` |
|
797 3. Compile the ``.tex`` file again. |
|
798 4. Compile the ``.tex`` file for one last time! |
|
799 |
|
800 Beamer |
|
801 ~~~~~~ |
737 |
802 |
738 LaTeX has quite a few options to produce presentation slides. We shall look at the ``beamer`` class, which is well developed and easy to use. We shall only briefly look at some of the features of beamer. For the best documentation, look at the beamer user guide. |
803 LaTeX has quite a few options to produce presentation slides. We shall look at the ``beamer`` class, which is well developed and easy to use. We shall only briefly look at some of the features of beamer. For the best documentation, look at the beamer user guide. |
739 |
804 |
740 To write a ``beamer`` presentation, it is recommended that you use one of the templates that beamer provides. We shall use the ``speaker_introduction`` template to get started with beamer. |
805 To write a ``beamer`` presentation, it is recommended that you use one of the templates that beamer provides. We shall use the ``speaker_introduction`` template to get started with beamer. |
741 |
806 |