You are on page 1of 5

Chapter 12

Publishing Documents using Weightage


LaTeX 6 marks

LaTeX Language
 LaTeX is essentially a markup language.
 LaTeX source consists of plain text with some parts of the text marked using markers
known as commands.
 LaTeX commands start with a \ (backslash) character.
 Command name may be a string of alphabetic letters only or may be a single non-
letter.
 LaTeX commands are case-sensitive.
 TeX Live, a software package of the TeX and LaTex combination.

LaTeX Package
 Modern word processing software operates in WYSIWYG.
 TeX was extended in LaTeX.
 LaTeX itself also can be extended.
 LaTeX hosted on the www.ctan.org website.
 Full form of CTAN is The Comprehensive TeX Archive Network
 It is extremely good for complex mathematical formula in nice looking and
appropriate way.

Using LaTeX
LaTeX documents are typically created using any plain text editor ( likeSciTE / gedit).
No Use Command
1 To define the document’s title \title
2 To specify the author(s) of \author
document.
3 To indicate the date the \date
document.
4 To explicitly specify logical \chapter,\section,
structure \subsection,\paragraph
 It is necessary to provide the title and the author if you want LaTex to create an
automatic title for you.
 Providing date is optional;if it is omitted then the date of compilation is used in the title.
 Both LaTeX and Tex file extension is .tex
 LaTeX has a command called pdflatex that produces the popular PDF (Portable
Document Format) format files.
 PDF files are very popular for sharing printable document on the web.
 PDF documents can be viewed in Ubuntu’s default document viewer, evince.
 Hence the edit-compile-view cycles becomes:-
o Edit the document using any plain text editor like gedit/SciTE
o Compile the document by issuing the command pdflatex filename at the
command prompt.
o View the generated PDF file by either opening it from the GUI or by issuing the
command evince pdffilename at the command prompt.
 SciTE has one advantage over gedit- one can compile & view the document from
within the SciTE program itself.

Presented by Nuzhat Ibrahim Memon 1


LaTeX Argument
 Some commands may accept additional information, which known as arguments.
 Example : \textcolor command accept the color.
 There are 2 types of arguments :
(1) Optional arguments :
It is not mandatory.
Enclosed in [ ] – square brackets and separate by comma
(2) Mandatory arguments :
It is mandatory if any.
Enclosed in { } – curly braces.
\documentclass [12pt] {article};
Command Name Optional Argu. Mandatory Argu.

LaTeX Characters
 Whitespace characters are the space, tab and new line.
 It converts all occurrences of multiple consecutive whitespace into a single space
character.
 To insert a break in lines use \\ at the end of each line.
 Reserved characters in LaTeX :
#, $, %, &, _, {, }, ^, ~, \
 Use follow term to use reserved characters :
\#, \$, \%, \&, \_, \{, \}, \^{}, \~{}, \textbackslash{}
 < must be written as \textless and > as \textgreater.
 The ` (grave accent or backquote) and ‘ (apostrophe or straight quote) are used around
text to put it in single quotes.
 Double quotes are produced by repeating them twice.

LaTeX Group
 LaTeX uses groups to mark portions of text.
 A group is enclosed between curly braces { and }.
 Groups are useful for applying few commands to a small amount of text such as a part
of a line, few lines or a paragraph.

Environment
 Where a multitude of commands must be applied or where some commands have to be
applied to large portions, LaTeX provides a facility called environment.
 For eg. Applying formatting a table or mathematical equation to several paragraphs
or whole sections.
 Environment begins with
\begin {environment-name}
 Environment ends with
\end {environment-name}
 Environment can be nested.
 LaTeX has several advanced features, including programming and automatically
generating parts of the documents or multiple documents (mail merge).

Comment
 % character marks the beginning of a comment.
 Comment is used to provide explanation for the complicated parts to makes it easy for
others to understand the code.
 Everything from the % character up to the end of the line is treated as a comment.
 It is completely ignored by the compilation process and hence never makes it into the
output.
Presented by Nuzhat Ibrahim Memon 2
Structure of a LaTeX Document
LaTeX document has 2 parts :
(1) Preamble
 It contains metadata.
 Metadata is information about the document.
(2) Content
 Content is always inside the environment document.
 Environment written between\begin {doc} and \end {doc}

Common Document Classes in the preamble


The very first element in the preamble must be \documentclass{document-class-name}
specifying the type of the document.
No Class Uses
1 article For writing individual articles.
2 book For writing entire books.
3 slides For creating presentation slides.
4 letter For writing letters.
5 beamer For generating presentation with Beamer package.

Common Options of Document Class in the Preamble


No Class Uses
1 10pt, 11pt, 12 pt Font size 10 (Default), 11, 12
2 a4paper,letterpaper, legalpaper Paper size : A4, Letter, Legal
3 Fleqn Displayed formulas and equations
4 Landscape Changes the layout of the document to print in
landscape mode

Commonly Used Packages


 There is a large community of LaTeX users who develop new LaTeX package or enhance
existing ones to cater to their own needs and then share them with others over the CTAN
(Comprehensive TeX Archive Network).
 We need to declare package in the preamble as \usepackage{package-name}
No Class Uses
1 amsmath It contains advanced math extensions developed for the American
Mathematical Society
2 Color To adds support for colored text
3 easylist It adds support for multilevel lists
4 geometry For page layout tasks paper size, margin& orientation.
5 listings Special features for including programming code
6 setspace For change line spacing

Document Environment of a Book


The document environment of a book is divided into 3 main parts :
No Part Command
1 Front matter \frontmatter
2 Main matter \mainmatter
3 Back matter \backmatter
 This structure has things like the title, the table of contents in the front matter.
 The bibliography, index and reference in the back matter.
 The primary content in the form of chapters, sections and subsections in the main
matter.

Presented by Nuzhat Ibrahim Memon 3


Main Contents Book’s Hierarchy Structure
The main contents of a book has a hierarchical structure :
No Part Command
1 Books divided into parts \part
2 Parts divided into chapters \chapter
3 Chapters divided into sections \section
4 Sections divided into subsections \subsection
5 Subsections divided into subsubsections \subsubsection
6 Subsubsections divided into paragraphs \paragraph
7 Paragraphs divided into subparagraphs \subparagraph
 Each accepts one compulsory argument, the title and one optional argument.
 The parts are numbered in Roman Numerals (I,II ,III, ….) while the chapters,
sections, subsections etc are numbered in Arabic numeral (1,2,3…). All chapters
are treated as appendices and get uppercase alphabetic numbering (A, B, C….)
 Pages in the front matter are numbered using roman numerals, while the pages in the
main matter and the back matter are numbered in Arabic numeral.
 The commands defining different elements of the document also have their starred
equivalents that are not numbered. For example, \section* can be used to create a
section that is not automatically numbered.
 \setcounter{setnumdepth}{3} ensures that elements up to level 3 (subsubsection) are
assigned number.
 \tableofcontents to generate well formatted table of contents (TOC)

LaTeX Typesets Books


 Create a new file in SciTE using the File->New
 Save the file using the File->Save.
 LaTeX file extension is .tex
 Compile LaTeX file with Tools->Build | Shortcut key : F7
 If the compilation was successful, select the Tools->Go and shortcut key is F5.

LaTeX Text Formatting


 Hyphenation algorithm is used to decide the most appropriate way of breaking the word
with a hyphen (-)
 LaTeX used the (~) tilde character to denote a non-breaking space.

LaTeX Font Family


LaTeX divides font families into three categories :
No Font Name Uses Command
1 Roman Default font. Tiny line or curve at the end of the \textrm{text}
(Serif) lines.
2 Sans Serif Do not have tiny line \textsf{text}
3 Monospace Used for computer code listings. Equal width for \texttt{text}
all characters
Font Size:-
\tiny, \scriptsize, \footnotesize, \small, \normalsize, \large, \LARGE, \huge and \Huge
\textbf-bold \textit- italic \emph-emphasis \textsc-small capital letters
\textsuperscript\textsubscript
Fixltx2e –package for superscript and subscript

LaTeX Paragraph formatting


No Class Uses
1 Setspace Singlespacemonehalfspace, doublespace and spacing{amount-
of-spacing}
Presented by Nuzhat Ibrahim Memon 4
2 Alignment Left, right and center
3 environment Flushleft, flushright and center
4 Indent \indent and \noindent
5 Verbatim Outputs everything inside it as it is without any processing
environment
6 Moreverb Listing environment with one mandatory argument line-
number-of-first-line for program code listing with line numbers.

Mathematical Content in LaTeX


 American Mathematical Society created amsmath, amssymb and amsfonts packages.
 amsmath package defines several environments for mathematical content.
 There are 2 ways of typesetting :
(1)Formulas (2)Equations
Please also refer Figure 12.4 (page no 252)
1 Superscript ^ (Caret)
2 Subscript _ (Underscore)
3 Square root \sqrt{x}
4 ∪ \cup
5 # \neq
Fractions \frac{numerator}{denominator}

Advantage of LaTeX

 LaTeX has several benefits. Just as TeX was extended to LaTeX, LaTeX itself also can be
extended. Anyone can create additional packages to enhance the features provided in
LaTeX, to add new features or to provide alternate implementations. Thousands of such
packages have been created by LaTeX users around the world to cater to different needs.
Most of them are free. They are hosted on the CTAN (The Comprehensive TeX Archive
Network) website at www.ctan.org.
 LaTeX is extremely good at laying out complex mathematical formulae in nice looking
and appropriate way.Because of this, it is quite popular among authors and publishers in
mathematics, engineering, computer science and other technical areas. Because it is open
source, highly systematic and is developed in the academic spirit of knowledge sharing
and collaboration, it is popular among academicians and scholars. People in these fields
use LaTeX, share their views and experiences, help one another, develop and share new
packages and drive the further development of LaTeX.
 LaTeX has built-in facilities to automatically update numbering and references and to
automatically create table of contents, indexes, and other such needs, taking a major
burden off the mind of the author.

Presented by Nuzhat Ibrahim Memon 5

You might also like