1 of 45

PUBLISHING DOCUMENTS USING LATEX

Ch:12

2 of 45

What is Latex

  • Latex is a document preparation system and document markup language widely used for communication.
  • It is a high quality typesetting system for creating documents.

3 of 45

Using Latex

  • To use latex, we need any Latex distribution software.
  • Tex Live is a very popular Latex distribution available in ununtu linux.
  • Latex document can be created in any plain text editor like gedit or Scite.
  • Latex can be used to produce the popular PDF format document.
  • PDF means Portable Document Format.

4 of 45

General features of Latex

  • It contains various commands that associate a meaning to them.
    • For eg. \title : To define document’s title
    • \author : To specify author name in document
    • \date : To indicate date
    • \chapter
    • \section
    • \subsection
    • \paragraph
  • The code is then compiled using latex system and output file is produced.

5 of 45

Latex

  • Both Tex and Latex use the file extension .tex
  • Latex has a command called pdflatex used to create a PDF file.
    • For eg. pdflatex filename can be used to compile at command prompt.
    • The created pdf file can then be viewed either using GUI based program or by giving command �evince pdffilename at command prompt.

6 of 45

Latex Language

  • Latex is a markup language.
  • Some part of text marked up using markers known as commands.
  • Latex command start with a \ character followed by command name. For eg. \title
  • Latex commands are case sensitive.
  • Some commands accept additional information called arguments. For eg. \date{Feb 2015}
  • Arguments in latex are of two types:
    • (1) Optional arguments (2) Mandatory arguments

7 of 45

Arguments

  • Arguments in latex are of two types:
    • (1) Optional arguments (2) Mandatory arguments
  • Optional arguments are written after the command name enclosed in square brackets. [ ]
    • For eg. \documentclass[12pt]
  • Mandatory argument are written after optional arguments enclosed in curly braces. { }
    • For eg. documentclass[12pt]{article}
  • Here 12pt is optional argument whereas article is mandatory argument.

8 of 45

Latex

  • Latex treats all white space characters as the same.
  • It converts all occurrences of multiple consecutive whitespace into a single space character.
  • A whitespace at the beginning of a line are generally ignored.
  • One or more consecutive blank lines are considered to mark the beginning of a new paragraph.
  • \\ is used to give line break in latex.

9 of 45

Latex Code

\documentclass[12pt]{article}

\title{Line handling in \Latex}

\date{May 2013}

\begin{document}

\section{Continuous Text}

\textsf{We have no wings, we cannot fly but we have legs to sail and climb by slow degrees and by and by the cloudy summits of our time}

\section{Text with seperate Lines}

\textsf{Heights by great men reached and kept \\were not attained by a sudden flight\\but they, while their companious slept,\\were toiling upwards in the night} \end{document}

10 of 45

Output

11 of 45

Reserved Characters

  • Some characters in latex have special meaning.
  • These characters cannot be used directly in latex coding.
  • \ sign is used to print these characters.
  • # 🡪 \#
  • $ 🡪 \$
  • % 🡪 \%
  • & 🡪 \&
  • _ 🡪 \_
  • { 🡪 \{
  • } 🡪 \}

12 of 45

Group

  • Latex uses groups to mark portions of text.
  • A group is enclosed between curly braces { and }

Environment

  • For a large portion of text latex provides a facility called environment.
  • An environment starts with �\begin{environment-name}
  • It gets completed with�\end{environment-name}
  • % sign is used for single line comment in latex.

13 of 45

To use latex, we need any ________software.

  • Latex distribution software

14 of 45

__________is a very popular Latex distribution available in ununtu linux.

Tex Live

15 of 45

Latex document can be created in which type of software?

any plain text editor like gedit or Scite.

16 of 45

What is the full form of PDF?

Portable Document Format.

17 of 45

What is the extension of Latex file?

.tex

18 of 45

Which command of Latex is used to create a PDF file?

pdflatex

19 of 45

Which command of Latex is used to view a PDF file?

evince pfdfilename

20 of 45

A Latex command starts with which character?

\

21 of 45

Some commands accept additional information called __________.

arguments

22 of 45

How many types of arguments are there in Latex?

2 Types

23 of 45

Name the types of arguments in Latex?

  1. Optional arguments

  • Mandatory arguments

24 of 45

Optional arguments are written after the command name enclosed in _____________ brackets.

square brackets. [ ]

25 of 45

Mandatory argument are written after optional arguments enclosed in _____________ brackets.

curly braces. { }

26 of 45

In the example “documentclass[12pt]{article}” which is optional argument?

[12pt]

27 of 45

In the example “documentclass[12pt]{article}” which is mandatory argument?

{article}

28 of 45

What is the use of \\ in Latex?

Linebreak

29 of 45

Structure of a Latex Document

A LaTeX document has two parts.

(1) Preamble (2) content

(1) The preamble contains metadata ie. Data about data.

The metadata is information about the document

For eg. What kind of document it is

who is the author

when was it created etc…

(2) The content part contains the actual contents written between \begin{document} and \end{document}

30 of 45

The Preamble

Latex supports creation of a wide variety of documents.

The first element in preamble must be \documentclass{document-class-name}

Document Class

Purpose

article

For writing individual articles.

book

For writing entire books.

slides

For creating presentation slides. It automatically sets larger font size.

letter

For writing letters

beamer

For generating presentations similar to office suites using the beamer package.

31 of 45

Other Options of document class

Document Class

Purpose

10pt

Sets the size of main font in the document to 10 points

A4paper,

Letterpaper

Legalpaper

Defines the paper size.

Fleqn

Displayed formulas and equctions are flushed left.

Landscape

Changes the layout of the document to print in landscape mode

32 of 45

The document class declaration is followed by optional package declaration.

Latex itself provides many common typesetting requirements

Latex also allows users to write packages that provide additional functionality.

There is a large community of LaTeX users who develop new LaTeX packages or enhance existing ones to cater to their own needs and then share them with others over the comprehensive TeX Archive network(CTAN)

33 of 45

To use one or more packages in our documents, we need to declare them in the preamble as \usepackage{package-name}

Package

Description

Amsmath

Contains the advanced math extensions developed for American Mathematical Society

Color

Adds support for colored text

Easylist

Adds support for multilevel lists

Geometry

For page layout taks like setting paper size, orientation margins etc.

Listings

Has special features for including programming code within the document.

setspace

Lets you change line spacing

34 of 45

The Document Environment

The document environments for articles and slides will only have a title followed by the main content of the document.

A title is automatically generated by LaTeX when it sees the \maketitle command.

The document environment of a book is divided into three main parts.

(1) The front matter

(2) The main matter

(3) The back matter

35 of 45

The title, table of contents and the preface comes in the front matter.

The primary contents in the form of chapters, sections and subsections comes in the main matter.

The bibliography, index and references comes in the back matter.

36 of 45

The main contents of a book has a hierarchical structure, where

a book is divided into parts

Parts are divided into chapters

Chapters are divided into sections

Sections are divided into subsections

Subsections are divided into subsubsections

Subsubsections are divided into paragraphs

Paragraphs are divided into subparagraphs.

Each one of these accepts one compulsory argument, the title and one optional argument, title for table of contents.

37 of 45

The parts, chapters, sections are numbered automatically by LaTeX.

The parts are numbered in Roman numerals (I, II, III )

The chapters, sections, subsections etc are numbered in Arabic numerals(1, 2, 3)

Pages in the front matter are numbered using Roman numerals(I,II,III)

pages in the main matter and back matter are numbered in Arabic numerals(1,2,3,).

For eg. \section* can be used to create a section that is not automatically numbered.

38 of 45

By default elements are assigned number up to level 2 that is up to section and subsection.

Sub subsections and further divisions are not assigned numbers.

This can be changed by modifying built-in counter commnad \setcounter

For eg. \setcounter{secnumdepth}{3}

Elements are assigned a number formed by appending a period(.) and the element number to the number of parent element.

Chapters are an exception as their assigned number does not have the part number and period in front of them.

39 of 45

TOC (Table of contents)

A well formatted table of contents(TOC) is automatically generated from element titles when it encounters \tableofcontents command

By default a TOC has entries up to level 2 (subsection)

It can be changed by altering the vlaue of built-in counter tocdepth.

Normally Latex processes the source file sequentially from beginning to end.

It cannot move back and forth.

To create TOC, Latex runs the file twice because TOC comes at the beginning of a book in front matter.

40 of 45

Creating file in Latex

Start SciTE.

Select File 🡪 New

Write the Latex code.

Select File 🡪 save

Select Tools 🡪 Build or press F7

The out put window will show several message. If the last line (in blue rolor) reads Exit code:0 then compilation was successful.

Select Tools 🡪 Go or press F5.

41 of 45

Using Mathematical Symbols

Letters of Greek alphabet have their corresponding commands like \alpha , \beta , \gema , \pi etc.

These words with lower case letters produce lower case symbol.

The same commands, when used with the first letter in uppercase produces capital Greek letter.

42 of 45

Other symbols

43 of 45

Other symbols

44 of 45

Other symbols

45 of 45

Using Mathematical Operators

The power operator (x2) and the index operator(x1) are implemented using the the generic superscript operator (^) and (_) respectedly.

x2 can be written as x^2

Same way x1 can be written as x_1

Absolute values can be denoted by enclosing the expression between two | (Vertical bar) Symbols.

Fractions are created using the command \frac{Numerator}{Denominator}.

\sqrt{x} is used to display square root of x.

These operators can also be nested one inside another.