Introduction to L A T EX A Brief Summary of L A T EX Ashik Iqubal - - PowerPoint PPT Presentation

introduction to l a t ex
SMART_READER_LITE
LIVE PREVIEW

Introduction to L A T EX A Brief Summary of L A T EX Ashik Iqubal - - PowerPoint PPT Presentation

Introduction to L A T EX A Brief Summary of L A T EX Ashik Iqubal Department of Physics Ramakrishna Mission Vivekananda University Belur Math, Howrah ashik.iqubal@gmail.com August 3, 2012 T EX: Introduction Its a low-level markup and


slide-1
SLIDE 1

Introduction to L

AT

EX

A Brief Summary of L

AT

EX Ashik Iqubal

Department of Physics Ramakrishna Mission Vivekananda University Belur Math, Howrah ashik.iqubal@gmail.com

August 3, 2012

slide-2
SLIDE 2

T EX: Introduction

It’s a low-level markup and programming language created by Donald Knuth used to typeset documents attractively and consistently.

  • A. Iqubal

L

A

T EX

slide-3
SLIDE 3

T EX: Introduction

It’s a low-level markup and programming language created by Donald Knuth used to typeset documents attractively and consistently. Knuth started writing T EX typesetting engine in 1977 and released in 1978

  • A. Iqubal

L

A

T EX

slide-4
SLIDE 4

T EX: Introduction

It’s a low-level markup and programming language created by Donald Knuth used to typeset documents attractively and consistently. Knuth started writing T EX typesetting engine in 1977 and released in 1978 T EX was developed with two goals: to produce high quality documents, and to produce a system that would produce consistent results irrespective of platform or time

  • A. Iqubal

L

A

T EX

slide-5
SLIDE 5

T EX: Features

T EX is the one of the most sophisticated digital typographical system in the world

  • A. Iqubal

L

A

T EX

slide-6
SLIDE 6

T EX: Features

T EX is the one of the most sophisticated digital typographical system in the world T EX is a programming environment ,eg, it supports if-else construct, it can do calculations

  • A. Iqubal

L

A

T EX

slide-7
SLIDE 7

T EX: Features

T EX is the one of the most sophisticated digital typographical system in the world T EX is a programming environment ,eg, it supports if-else construct, it can do calculations T EX engine is extremely stable, runs on various platforms, and is virtually bug free

  • A. Iqubal

L

A

T EX

slide-8
SLIDE 8

T EX: Features

T EX is the one of the most sophisticated digital typographical system in the world T EX is a programming environment ,eg, it supports if-else construct, it can do calculations T EX engine is extremely stable, runs on various platforms, and is virtually bug free T EX is a popular means to typeset complex mathematical formulae, specially among academics

  • A. Iqubal

L

A

T EX

slide-9
SLIDE 9

T EX: Features

T EX is the one of the most sophisticated digital typographical system in the world T EX is a programming environment ,eg, it supports if-else construct, it can do calculations T EX engine is extremely stable, runs on various platforms, and is virtually bug free T EX is a popular means to typeset complex mathematical formulae, specially among academics It is a free / open source software

  • A. Iqubal

L

A

T EX

slide-10
SLIDE 10

L

AT

EX: Introduction

Inspite of T EX being a powerful engine, it requires a considerable learning curve, and requires building custom macros for text formatting

  • A. Iqubal

L

A

T EX

slide-11
SLIDE 11

L

AT

EX: Introduction

Inspite of T EX being a powerful engine, it requires a considerable learning curve, and requires building custom macros for text formatting L

AT

EX is a document markup language and document preparation system based on T EX created by Leslie Lamport

  • A. Iqubal

L

A

T EX

slide-12
SLIDE 12

L

AT

EX: Introduction

Inspite of T EX being a powerful engine, it requires a considerable learning curve, and requires building custom macros for text formatting L

AT

EX is a document markup language and document preparation system based on T EX created by Leslie Lamport L

AT

EX comprises of a collection of T EX macros and a program to process L

AT

EXdocuments

  • A. Iqubal

L

A

T EX

slide-13
SLIDE 13

L

AT

EX: Introduction

Inspite of T EX being a powerful engine, it requires a considerable learning curve, and requires building custom macros for text formatting L

AT

EX is a document markup language and document preparation system based on T EX created by Leslie Lamport L

AT

EX comprises of a collection of T EX macros and a program to process L

AT

EXdocuments Since T EX formatting commands are very low-level, it is usually simpler for end-users to use L

AT

EX

  • A. Iqubal

L

A

T EX

slide-14
SLIDE 14

L

AT

EX: Features

L

AT

EX is based on the separation of layout from content, while still allowing manual typesetting adjustments when needed (similar to HTML). Can be called WYSIWYM (ie, What You See Is What You Mean)

  • A. Iqubal

L

A

T EX

slide-15
SLIDE 15

L

AT

EX: Features

L

AT

EX is based on the separation of layout from content, while still allowing manual typesetting adjustments when needed (similar to HTML). Can be called WYSIWYM (ie, What You See Is What You Mean) L

AT

EX can be arbitrarily extended by using underlying macro language to develop custom formats (generally in the form of packages or styles)

  • A. Iqubal

L

A

T EX

slide-16
SLIDE 16

L

AT

EX: Features

L

AT

EX is based on the separation of layout from content, while still allowing manual typesetting adjustments when needed (similar to HTML). Can be called WYSIWYM (ie, What You See Is What You Mean) L

AT

EX can be arbitrarily extended by using underlying macro language to develop custom formats (generally in the form of packages or styles) Complex Mathematical formulae can easily be typeset

  • A. Iqubal

L

A

T EX

slide-17
SLIDE 17

L

AT

EX: Features

L

AT

EX is based on the separation of layout from content, while still allowing manual typesetting adjustments when needed (similar to HTML). Can be called WYSIWYM (ie, What You See Is What You Mean) L

AT

EX can be arbitrarily extended by using underlying macro language to develop custom formats (generally in the form of packages or styles) Complex Mathematical formulae can easily be typeset Indexes, footnotes, citations, references, etc are automatically generated

  • A. Iqubal

L

A

T EX

slide-18
SLIDE 18

L

AT

EX: Features

L

AT

EX is based on the separation of layout from content, while still allowing manual typesetting adjustments when needed (similar to HTML). Can be called WYSIWYM (ie, What You See Is What You Mean) L

AT

EX can be arbitrarily extended by using underlying macro language to develop custom formats (generally in the form of packages or styles) Complex Mathematical formulae can easily be typeset Indexes, footnotes, citations, references, etc are automatically generated Consistent layout, tables, fonts, etc throughout the document

  • A. Iqubal

L

A

T EX

slide-19
SLIDE 19

L

AT

EX: Features

L

AT

EX is based on the separation of layout from content, while still allowing manual typesetting adjustments when needed (similar to HTML). Can be called WYSIWYM (ie, What You See Is What You Mean) L

AT

EX can be arbitrarily extended by using underlying macro language to develop custom formats (generally in the form of packages or styles) Complex Mathematical formulae can easily be typeset Indexes, footnotes, citations, references, etc are automatically generated Consistent layout, tables, fonts, etc throughout the document Document structure can be easily copied to another document

  • A. Iqubal

L

A

T EX

slide-20
SLIDE 20

L

AT

EX: Basics

Example \documentclass {article} \begin{document} Hello World ! ! ! \end{document}

  • A. Iqubal

L

A

T EX

slide-21
SLIDE 21

L

AT

EX: Spaces

Consecutive ”Whitespace” characters are treated as a single space ”Whitespace” at the beginning of a line is generally ignored Single line break is treated as ”whitespace” Empty line between two lines denotes change of paragraph Several empty lines are treated as one empty line

  • A. Iqubal

L

A

T EX

slide-22
SLIDE 22

L

AT

EX: Special Characters

Following are reserved characters that have special meaning in L

AT

EX : # & $ \ ˆ ˜ { } % Special characters can be used in the document adding a backslash \ as prefix : \# \& \$ \textbackslash{} \textasciicircum{} \ \˜{} \{ \} \% Backslash can be entered in math mode as \backslash

  • A. Iqubal

L

A

T EX

slide-23
SLIDE 23

L

AT

EX: Commands

Case sensitive Starts with backslash \ followed by one ”non-letter” or multiple letters and terminated by space, number or ”non-letter” Argument is given between curly braces {} and optional parameters between square brackets [ ] L

AT

EXCode \command [ option1, option2, ... ] {argument1} {argument2}

  • A. Iqubal

L

A

T EX

slide-24
SLIDE 24

L

AT

EX: Groups

Defined and limited by a pair of curly braces {} Example { \bf Bold font text }

  • A. Iqubal

L

A

T EX

slide-25
SLIDE 25

L

AT

EX: Environment

L

AT

EXCode \begin{environment} Contents under influence of the environment \end{environment}

  • A. Iqubal

L

A

T EX

slide-26
SLIDE 26

L

AT

EX: Comments

When L

AT

EXencounters % it ignores the rest of the current line, line break and all the whitespace at the beginning of the next line

  • A. Iqubal

L

A

T EX

slide-27
SLIDE 27

L

AT

EX: Document Classes

Every L

AT

EXfile starts with the following L

AT

EXCode \documentclass[options]{class} Example \documentclass[11pt,twoside,a4paper]{article}

  • A. Iqubal

L

A

T EX

slide-28
SLIDE 28

L

AT

EX: Document Class - {class}

Examples of document classes: article articles in scientific journals, short reports, etc. report longer reports containing several chapters, small books, thesis, etc. book real books letter writing letters slides slides with big sans serif fonts beamer writing presentation

  • A. Iqubal

L

A

T EX

slide-29
SLIDE 29

L

AT

EX: Document Class - [options]

Examples of document class options: ?pt sets the size of the main font of the document, eg. 10pt, 11pt, 12pt ?paper defines the paper size, eg, a4paper, letterpaper, legalpaper, a5paper, etc. ?column instructs L

AT

EXto typeset in one or two columns, eg.

  • necolumn, twocolumn

?side specifies whether double or single sided output should be generated landscape landscape mode draft makes LaTeX indicate hyphenation and justification problems in the right-hand margin of the problem line

  • A. Iqubal

L

A

T EX

slide-30
SLIDE 30

L

AT

EX: Packages

Packages in L

AT

EX are activated using L

AT

EXCode \usepackage[options]{package} Example \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb}

  • A. Iqubal

L

A

T EX

slide-31
SLIDE 31

L

AT

EX: Preamble

In L

AT

EX, preamble is the part from the beginning of the document until \begin{document}. It consists of commands affecting the entire document. Example % Preamble \documentclass[a4paper]{article} \usepackage{amsmaths} % Preamble \begin{document}

  • A. Iqubal

L

A

T EX

slide-32
SLIDE 32

L

AT

EX: File input

L

AT

EX files ( filename.tex ) are inserted into a document using L

AT

EXCode \input{filename}

  • r

\include{filename} Using \include{filename}, the output is added to the document, unlike \input{filename} where the commands are added into the document. Therefore new page will be created with every \include command.

  • A. Iqubal

L

A

T EX

slide-33
SLIDE 33

L

AT

EX: Top Matter

To include information about the document itself, like title, author, date, etc Example \documentclass[a4paper]{article} \begin{document} \title{Title of the L

AT

EX document} \author{Humpty \and Dumpty \\ RKMVU \\ \texttt{userid@server.com} } \date{\today } \maketitle .............. \end{document} The command \maketitle creates the title page

  • A. Iqubal

L

A

T EX

slide-34
SLIDE 34

L

AT

EX: Top Matter - Abstract

To include an abstract: Example \documentclass[a4paper]{article} \begin{document} \begin{abstract} The abstract goes in here.......... \end{abstract} The main body of the document goes in here.......... \end{document}

  • A. Iqubal

L

A

T EX

slide-35
SLIDE 35

L

AT

EX: Sectioning

Except in letter class, any document can have sections, subsections, subsubsections, etc. L

AT

EXCode \section[TOC Header Name]{Section Name} ...... \subsection[TOC Header Name]{Sub-Section Name} .............. \subsubsection[TOC Header Name]{Sub-Sub-Section Name} ............... In book class, the document can have chapters L

AT

EXCode \chapter{Chapter Name} ............

  • A. Iqubal

L

A

T EX

slide-36
SLIDE 36

L

AT

EX: Appendices

In article class, appendix is given by L

AT

EXCode \appendix \section{First Appendix} .............. In report or book class, appendix is given by L

AT

EXCode \appendix \chapter{First Appendix} ..................

  • A. Iqubal

L

A

T EX

slide-37
SLIDE 37

L

AT

EX: Table of Contents

In L

AT

EX, the Table of Contents is generated automatically L

AT

EXCode \tableofcontents Including the command \tableofcontents generates the TOC at that point

  • A. Iqubal

L

A

T EX

slide-38
SLIDE 38

L

AT

EX: Text Alignment

L

AT

EXCode \begin{alignment} ....... \end{alignment} The option alignment can take the following values center center aligned flushright left aligned flushleft right aligned

  • A. Iqubal

L

A

T EX

slide-39
SLIDE 39

L

AT

EX: Text Size

L

AT

EXCode { \size ....... } The option size can take the following values Huge Huge huge huge LARGE LARGE Large Large large large small small footnotesize footnotesize tiny

tiny

  • A. Iqubal

L

A

T EX

slide-40
SLIDE 40

L

AT

EX: Text Character

L

AT

EXCode { \textbf Gives Bold Font } { \textit Gives Italics } { \underline Underlines the Text }

  • A. Iqubal

L

A

T EX

slide-41
SLIDE 41

L

AT

EX: Items

L

AT

EXCode \begin{itemize} \item[item symbol] ........ \item[item symbol] ........ ........ \end{itemize} Example ........ ........ ........

  • A. Iqubal

L

A

T EX

slide-42
SLIDE 42

L

AT

EX: Enumeration

L

AT

EXCode \begin{enumerate} \item ........ \item ........ ........ \end{enumerate} Example

1 ........ 2 ........ 1 ...... 2 ......

........

  • A. Iqubal

L

A

T EX

slide-43
SLIDE 43

L

AT

EX: Including Graphics

To add grahics to the document, the graphicx package needs to be included in the preamble L

AT

EXCode \usepackage{graphicx} To include an imagefile in the document : L

AT

EXCode \includegraphics[arrt1=val1,attr=val2,....]{imagefile}

  • A. Iqubal

L

A

T EX

slide-44
SLIDE 44

L

AT

EX: Including Graphics contd.

L

AT

EXCode \includegraphics[arrt1=val1,attr=val2,....]{imagefile} The attributes can be specified as follows: width=xx width of image height=xx height of image keepaspectratio preserves the aspect ratio can be set to true or false scale=xx scales the image by factor xx angle=xx rotates the image by angle xx degrees (counter clockwise) trim=l b r t crops the image by l from left, b from bottom, r from right and t from top page=x if image is a pdf file with multiple pages, selects the image on page x

  • A. Iqubal

L

A

T EX

slide-45
SLIDE 45

L

AT

EX: Including Graphics as Figure

To include an imagefile as a figure, L

AT

EXCode \begin{figure}[placement specifier] \centering \includegraphics[attr1=val1]{imagefile} \caption{Awesome Image} \label{fig:awesomeimage} \end{figure} Use \listoffigures to add a list of figures to the beginning of document

  • A. Iqubal

L

A

T EX

slide-46
SLIDE 46

L

AT

EX: Including Graphics as Figure

L

AT

EXCode \begin{figure}[placement specifier] \end{figure} The placement specifier can take the following values h place float here (approximately) H place float precisely at the location of L

AT

EX code requires the use of float package \usepackage{float} ! override internal parameters L

AT

EX uses t top of page b bottom of page p special page

  • A. Iqubal

L

A

T EX

slide-47
SLIDE 47

L

AT

EX: Text Wrapping Around Image

To wrap text around images, the following package can be added in the preamble L

AT

EXCode \usepackage{wrapfig} To place imagefile in the document L

AT

EXCode \begin{wrapfigure}{pos}{Xcm} \centering \includegraphics[attr1=val1]{imagefile} \caption{Awesome Image} \label{fig:awesomeimage} \end{wrapfigure}

  • A. Iqubal

L

A

T EX

slide-48
SLIDE 48

L

AT

EX: Text Wrapping Around Image contd.

L

AT

EXCode \begin{wrapfigure}{pos}{Xcm} \includegraphics[attr1=val1]{imagefile} \end{wrapfigure} Here pos can take eight possible values r \ R right side of text l \ L left side of text i \ L inside edge (ie, near binding in twoside document)

  • \ O outer edge (ie, far from binding in twoside document)

The upper-case allows the figure to float, while lower case means ”exactly here” X is the width of the figure. Can be specified as a factor of \textwidth, eg., 0.5\textwidth

  • A. Iqubal

L

A

T EX

slide-49
SLIDE 49

L

AT

EX: Tables

Tables are generated in L

AT

EX using the following format in general L

AT

EXCode \begin{table}[position specifier h, t, b, p] \centering \begin{tablular}{|| l | c| c | c | r || } .... table .......... \end{tablular} \caption{Table Caption} \label{label:table} \end{table} Use \listoftables to generate a list of tables in the beginning of document

  • A. Iqubal

L

A

T EX

slide-50
SLIDE 50

L

AT

EX: Table Environment

L

AT

EXCode \begin{table}[position specifier] \end{table} The position specifier can take the following values h here !h force here t top b bottom p page

  • A. Iqubal

L

A

T EX

slide-51
SLIDE 51

L

AT

EX: Tabular Environment

L

AT

EXCode \begin{tablular}[pos]{table spec} .... table .......... \end{tablular} The table spec can take the following values l left-justified column c centered column r right-justified column p{width} paragraph column with text vertically aligned at the top m{width} paragraph column with text vertically aligned in the middle (requires array package) b{width} paragraph column with text vertically aligned at the bottom (requires array package) | vertical line || double vertical line

  • A. Iqubal

L

A

T EX

slide-52
SLIDE 52

L

AT

EX: Tabular Environment contd.

L

AT

EXCode \begin{tablular}[pos]{table spec} .... table .......... \end{tablular} The optional parameter pos specifies the vertical position of the table relative to the baseline of surrounding text b bottom c center t top

  • A. Iqubal

L

A

T EX

slide-53
SLIDE 53

L

AT

EX: Tabular Environment contd.

L

AT

EXCode \begin{tablular}[pos]{table spec} .... table data ....... \end{tablular} The table data is entered using the following commands & column separator \\ starts new row (additional space may be specified after \\ using square brackets [Xpt] ) \hline horizontal line \newline starts new line within a cell \cline{i-j} partial horizontal line beginning in column i and ending in column j

  • A. Iqubal

L

A

T EX

slide-54
SLIDE 54

L

AT

EX: Tabular Environment contd.

Example 7C0 hexadecimal 3700

  • ctal

11111000000 binary 1984 decimal

Table : This table shows some data

  • A. Iqubal

L

A

T EX

slide-55
SLIDE 55

L

AT

EX: Tabular Environment contd.

Example \begin{table}[h] \centering \begin{tabular}{|r|l|} \hline 7C0 & hexadecimal \\ 3700 & octal \\ \cline{2-2} 11111000000 & binary \\ \hline \hline 1984 & decimal \\ \hline \end{tabular} \caption{This table shows some data} \end{table}

  • A. Iqubal

L

A

T EX

slide-56
SLIDE 56

L

AT

EX: Labels and Cross-Referencing

To label something (section, figure, formulas, etc.) in a document, it is marked with a \label{tag} To refer to that label, ˜\ref{tag} is used To refer to that labelled page, ˜\pageref{tag} is used For referring to equations, one can use ˜\eqref{tag}. (For this the amsmath package needs to be included in the preamble) To create hyperlink, use \usepackage{hyperref} and \usepackage[all]{hypcap} in the preamble (in the order mentioned). And use ˜\autoref{tag} to refer to that label Run pdflatex twice to generate all the cross-referencing correctly

  • A. Iqubal

L

A

T EX

slide-57
SLIDE 57

L

AT

EX: Hyperlink

To create hyperlinks, use \usepackage{hyperref} in the preamble \url{http://...........} creates a hyperlink to the link \href{http://...........}{url description} creates a hyperlink to the link and also displays the url description For email links, \href{mailto:user@server.com}{user@server.com}

  • A. Iqubal

L

A

T EX

slide-58
SLIDE 58

L

AT

EX: Bibliography

Add the list of Bibliography at the end of the document, immediately before \end{document}. The items in the Bibliography can be cited using ˜\cite{tag} Example \begin{thebibliography}{99} \bibitem{lamport94} Leslie Lamport, \emph{\LaTeX: A Document Preparation System}. Addison Wesley, Massachusetts, 2nd Edition, 1994. \bibitem{tag} ........... \end{thebibliography}

  • A. Iqubal

L

A

T EX

slide-59
SLIDE 59

L

AT

EX: Including Figure from Xfig

Create a figure in Xfig. When needed, use L

AT

EX text like mathematical formulas, etc. in the textbox. Edit the textbox and change the option on ”Special Flag” field to Special. Export the Xfig figure as ”Combined PDF/LaTeX” (or ”Combined PS/LaTeX”). Two files with the extension *.pdf t and *.pdf ( or *.pstex t and *.pstex) will be created in the same directory. Include the figure using the following : L

AT

EXCode \begin{figure} \centering \input{xfig-figure.pdf t} \caption{Caption of figure} \label{fig:test} \end{figure}

  • A. Iqubal

L

A

T EX