+ All Categories
Home > Documents > Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ...

Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ...

Date post: 18-Aug-2020
Category:
Upload: others
View: 3 times
Download: 0 times
Share this document with a friend
78
Introduction to Latex Stelios Vrachimis, Alexis Kyriacou February 01, 2020 University of Cyprus References: https://www.latex-tutorial.com/ Manolis Christodoulakis, ΚΕΔΙΜΑ 2012
Transcript
Page 1: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Overview

1 LATEX basics

2 Document Structure

3 Document Formatting

4 Packages

5 Tables and Figures

6 Mathematics

7 Appendix A Customizing LATEX

8 Appendix B The AMS-LATEX bundle

9 Appendix C Dealing with Greek characters

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 2 / 87

Introduction to Latex

Stelios Vrachimis, Alexis Kyriacou

February 01, 2020

University of Cyprus

References:• https://www.latex-tutorial.com/• Manolis Christodoulakis, ΚΕΔΙΜΑ 2012

Page 2: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Introduction to LATEX

Manolis Christodoulakis

Department of Electrical and Computer EngineeringUniversity of Cyprus

[email protected]

September 22, 2012

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 1 / 87

Overview

1 LATEX basics

2 Document Structure

3 Document Formatting

4 Packages

5 Tables and Figures

6 Mathematics

7 Appendix A Customizing LATEX

8 Appendix B The AMS-LATEX bundle

9 Appendix C Dealing with Greek characters

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 2/78

Page 3: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

What is LATEX?

Pronounced ‘Lah Tek’ or ‘Lay Tek’

It is a document markup language and a document preparation system

Document Markup Language

A plain text file, the source,contains the text along withmarkup commands, such as‘title’, ‘section’, ‘figure’ etc.

Document Preparation System

A set of software, such as latexand pdflatex, processes thesource file and produces theoutput, e.g. pdf

A bit of history

In 1978, Donald Knuth (a well known computerscientist) got frustrated with the mistakes thathis publishers made in typesetting his work

So he decided to create his own typesettingsystem, one that would be easy to use,especially for typesetting mathematicalformualae

He called his system TEX and made it freelyavailable

The problem with TEX was that it was focusingtoo much on the details

For this reason, a few years later LeslieLamport created LATEX, which focuses ondocument structure rather than such details

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 5 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 3/78

Page 4: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

What is LATEX?

Pronounced ‘Lah Tek’ or ‘Lay Tek’

It is a document markup language and a document preparation system

Document Markup Language

A plain text file, the source,contains the text along withmarkup commands, such as‘title’, ‘section’, ‘figure’ etc.

Document Preparation System

A set of software, such as latexand pdflatex, processes thesource file and produces theoutput, e.g. pdf

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 4 / 87

A bit of history

In 1978, Donald Knuth (a well known computerscientist) got frustrated with the mistakes thathis publishers made in typesetting his work

So he decided to create his own typesettingsystem, one that would be easy to use,especially for typesetting mathematicalformualae

He called his system TEX and made it freelyavailable

The problem with TEX was that it was focusingtoo much on the details

For this reason, a few years later LeslieLamport created LATEX, which focuses ondocument structure rather than such details

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 4/78

Page 5: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Advantages of using LATEX

Separation of content and style

Scalability – can be used for a one-page letter or a 300 page book

High quality output – PDFs produced look elegant and professional

Performance – LATEX doesnt crash like Word

Can be used with the bibliography/reference package bibTEX

Files are very small – a LATEX file is just a text file

It’s free

Platform independent – can be used on Windows, Mac, Linux

Disadvantages of using LATEX

It can be a bit overwhelming at first

Learning how to use it takes time

Complicated workflow – there are several steps to write, generate andproduce a finished file

Just as with any software, there are occasional bugs

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 7 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 5/78

Page 6: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Advantages of using LATEX

Separation of content and style

Scalability – can be used for a one-page letter or a 300 page book

High quality output – PDFs produced look elegant and professional

Performance – LATEX doesnt crash like Word

Can be used with the bibliography/reference package bibTEX

Files are very small – a LATEX file is just a text file

It’s free

Platform independent – can be used on Windows, Mac, Linux

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 6 / 87

Disadvantages of using LATEX

It can be a bit overwhelming at first

Learning how to use it takes time

Complicated workflow – there are several steps to write, generate andproduce a finished file

Just as with any software, there are occasional bugs

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 6/78

Page 7: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Installing LATEX

1 The LATEX engine (the ‘software’) – requiredI MikTeX for MS Windows (http://miktex.org/)I MacTeX for Mac (http://www.tug.org/mactex/)

2 One LATEX editor – optional, but highly recommended!

TexStudio for MS Windows (https://www.texstudio.org/) Texmaker for MS Windows (http://www.xm1math.net/texmaker/) Texnic Center for MS Windows (http://www.texniccenter.org/) Latexian for Mac (http://tacosw.com/latexian) TeXShop for Mac (http://www.uoregon.edu/~koch/texshop/)

Note

Normally, you don’t fiddle with the LATEX engine on your own (through thecommand prompt), only via the LATEX editor.

The LATEX source file

Example\documentclassarticle

\begindocument

This is my first document! It

is very simple indeed!

\enddocument

The LATEX source file:

is a plain text file

by convention its file namehas extension .tex

contains all the contenttogether with markupcommands

LATEX commands

Every LATEX command starts with a backslash (\) followed by thecommand’s name. Many LATEX commands are further followed by one ormore arguments, which go in curly brackets.

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 9 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 7/78

Page 8: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Installing LATEX

1 The LATEX engine (the ‘software’) – requiredI MikTeX for MS Windows (http://miktex.org/)I MacTeX for Mac (http://www.tug.org/mactex/)

2 One LATEX editor – optional, but highly recommended!I Texmaker for MS Windows (http://www.xm1math.net/texmaker/)I Texnic Center for MS Windows (http://www.texniccenter.org/)I Latexian for Mac (http://tacosw.com/latexian)I TeXShop for Mac (http://www.uoregon.edu/~koch/texshop/)

Note

Normally, you don’t fiddle with the LATEX engine on your own (through thecommand prompt), only via the LATEX editor.

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 8 / 87

The LATEX source file

Example\documentclassarticle

\begindocument

This is my first document! It

is very simple indeed!

\enddocument

The LATEX source file:

is a plain text file

by convention its file namehas extension .tex

contains all the contenttogether with markupcommands

LATEX commands

Every LATEX command starts with a backslash (\) followed by thecommand’s name. Many LATEX commands are further followed by one ormore arguments, which go in curly brackets.

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 8/78

Page 9: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Document class

Every LATEX document starts by declaring what document class it belongsto, by using the command \documentclass.There are four built-in classes provided, and many others you candownload

report for business, technical, legal, academic, or scientific reports

article for white papers, magazine or journal articles, reviews,conference papers, or research notes

book for books and theses

letter for letters

The most common of these is the article.

The document environment

The actual document goes between the commands \begindocumentand \enddocument.

Above the \begindocument command (and below the\documentclass) we will be able to insert extra setup specifications;this area of the source file is known as the preamble

Anything placed underneath the \enddocument command isignored

LATEX environment

The \begin. . . \end pair of commands is called an environment.Environments enclose text which is to be handled in a particular way. Allenvironments start with \begin... and end with \end... (puttingthe name of the environment in the curly braces).

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 11 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 9/78

Page 10: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Document class

Every LATEX document starts by declaring what document class it belongsto, by using the command \documentclass.There are four built-in classes provided, and many others you candownload

report for business, technical, legal, academic, or scientific reports

article for white papers, magazine or journal articles, reviews,conference papers, or research notes

book for books and theses

letter for letters

The most common of these is the article.

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 10 / 87

The document environment

The actual document goes between the commands \begindocumentand \enddocument.

Above the \begindocument command (and below the\documentclass) we will be able to insert extra setup specifications;this area of the source file is known as the preamble

Anything placed underneath the \enddocument command isignored

LATEX environment

The \begin. . . \end pair of commands is called an environment.Environments enclose text which is to be handled in a particular way. Allenvironments start with \begin... and end with \end... (puttingthe name of the environment in the curly braces).

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 10/78

Page 11: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Producing a LATEX documentCreating the source file

Open the LATEX editor (e.g. TeXmaker)Click on New to create a new documentAdd your latex code in the fileClick on Save and select a folder to store your .tex file

Producing a LATEX documentProcessing the source file

There are generally two ways to process a LATEX source file

Using the latex software produces a .dvi file. This can be furtherprocessed to transform the output to postscript (.ps) or pdf format.

In Texmaker:Using the pdflatex software transforms the .tex source file directly

to pdf. In Texmaker:

Tip 1

pdflatex is the one used most often. For this reason Texmaker providesa button Quick Build, which both calls the pdflatex and opens the

resulting pdf file

Tip 2

There is no need to click on Save (except for the very first time you createthe document). With Quick Build, the document is saved automatically.

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 13 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 11/78

Page 12: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Producing a LATEX documentCreating the source file

Open the LATEX editor (e.g. TeXmaker)Click on New to create a new documentAdd your latex code in the fileClick on Save and select a folder to store your .tex file

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 12 / 87

Producing a LATEX documentProcessing the source file

There are generally two ways to process a LATEX source file

Using the latex software produces a .dvi file. This can be furtherprocessed to transform the output to postscript (.ps) or pdf format.

In Texmaker:Using the pdflatex software transforms the .tex source file directly

to pdf. In Texmaker:

Tip 1

pdflatex is the one used most often. For this reason Texmaker providesa button Quick Build, which both calls the pdflatex and opens the

resulting pdf file

Tip 2

There is no need to click on Save (except for the very first time you createthe document). With Quick Build, the document is saved automatically.

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 12/78

Page 13: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Producing a LATEX documentTools and shortcuts

In Texmaker, you can find all the available tools for producing a LATEXdocument under the menu Tools

Note

Notice that the key F1 is associated withQuick Build

White space in the source file

ExampleThis is a paragraph

that shows clearly

that two or more spaces

are treated as a single

space

Leaving one more empty

lines creates a new

paragraph. Note: it does

NOT create empty lines in

the document!

LATEX protects you from accidentallyadding more than one spacesbetween words, by treating multiplespaces as a single space.

Multiple empty lines are interpretedas a single empty line, which itselfsignifies a change of paragraph.

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 15 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 13/78

Page 14: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Producing a LATEX documentTools and shortcuts

In Texmaker, you can find all the available tools for producing a LATEXdocument under the menu Tools

Note

Notice that the key F1 is associated withQuick Build

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 14 / 87

White space in the source file

ExampleThis is a paragraph

that shows clearly

that two or more spaces

are treated as a single

space

Leaving one more empty

lines creates a new

paragraph. Note: it does

NOT create empty lines in

the document!

LATEX protects you from accidentallyadding more than one spacesbetween words, by treating multiplespaces as a single space.

Multiple empty lines are interpretedas a single empty line, which itselfsignifies a change of paragraph.

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 14/78

Page 15: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Title, Author, Date

The title, author and date provide information about the document andfor this reason are known as metadata.

Example\documentclassarticle

\titleIntroduction to LaTeX\authorStelios and Alexis\\Univ. of Cyprus \dateMarch 2018

\begindocument

\maketitle

Main text goes here.

\enddocument

Metadata can be placedin the preamble

\maketitle tells LATEXthat the metadata iscomplete and should betypeset; if you omit it,no title will be print

If \date is omitted,today’s date will be print

The command \\creates a new line

AbstractTo typeset an abstract in your document, you use the abstractenvironment.

Example\documentclassarticle

...

\begindocument

\maketitle

\beginabstract

Latex is a professional typesetting language and document

preparation system. It can be used to create all sorts

of documents.

In this article we will introduce the most basic LaTeX

commands and will provide practical examples.

\endabstract

Main text goes here.

\enddocument

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 18 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 15/78

Page 16: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Title, Author, Date

The title, author and date provide information about the document andfor this reason are known as metadata.

Example\documentclassarticle

\titleIntroduction to LaTeX

\authorM. Christodoulakis\\Univ. of Cyprus

\dateJanuary 2012

\begindocument

\maketitle

Main text goes here.

\enddocument

Metadata can be placedin the preamble

\maketitle tells LATEXthat the metadata iscomplete and should betypeset; if you omit it,no title will be print

If \date is omitted,today’s date will be print

The command \\creates a new line

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 17 / 87

AbstractTo typeset an abstract in your document, you use the abstractenvironment.

Example\documentclassarticle

...

\begindocument

\maketitle

\beginabstract

Latex is a professional typesetting language and document

preparation system. It can be used to create all sorts

of documents.

In this article we will introduce the most basic LaTeX

commands and will provide practical examples.

\endabstract

Main text goes here.

\enddocument

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 16/78

Page 17: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Sections

There are seven levels of sectioning:

There also exists the \appendix command which does not take anargument, but it changes the chapter numbering to letters

Section numbering

LATEX automatically calculates the correct numbering of all types ofsections

Occasionally, you may want to have a section heading that is notnumbered

You can achieve this with the starred versions of the sectioncommands

...

\subsectionA numbered subsection

heading

Text of the first subsection ...

\subsection*This subsection is not

numbered

Text of the second subsection ...

Note

The starred versions of section commands are automatically excludedfrom the table of contents (if one is created)

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 20 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 17/78

Page 18: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Sections

There are seven levels of sectioning:

There also exists the \appendix command which does not take anargument, but it changes the chapter numbering to letters

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 19 / 87

Section numbering

LATEX automatically calculates the correct numbering of all types ofsections

Occasionally, you may want to have a section heading that is notnumbered

You can achieve this with the starred versions of the sectioncommands

...

\subsectionA numbered subsection

heading

Text of the first subsection ...

\subsection*This subsection is not

numbered

Text of the second subsection ...

Note

The starred versions of section commands are automatically excludedfrom the table of contents (if one is created)

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 18/78

Page 19: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Table of contents

To add a table of contents add the command \tableofcontents inthe place where you want the table printed (normally after theabstract)

You need to run pdflatex (or latex) twice in order to get thecorrect table of contents; the first time all section headings arerecorded and the second time they are printed

Similarly, there exist commands \listoffigures and\listoftables which automatically list all your tables and figures

Exercise

Task

Generate a new document in Texmaker, with document class article

Add your own titling information

Add custom text separated in sections and subsections

Place a table of contents at the beginning of your document

Generate the pdf output by pressing the Quick Build button (or theF1 key on your keyboard)

Questions1 What do you notice with the Table of Contents the first time you

compile your document?

2 Rebuild the document. Is the problem with the Table of Contentsfixed now?

3 Then, change the document class to report and rebuild. Whatdifferences do you notice?

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 22 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 19/78

Page 20: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Table of contents

To add a table of contents add the command \tableofcontents inthe place where you want the table printed (normally after theabstract)

You need to run pdflatex (or latex) twice in order to get thecorrect table of contents; the first time all section headings arerecorded and the second time they are printed

Similarly, there exist commands \listoffigures and\listoftables which automatically list all your tables and figures

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 21 / 87

Exercise

TaskGenerate a new document in Texstudio, with document class article Add your own titling information

Add custom text separated in sections and subsections

Place a table of contents at the beginning of your document Generate the pdf output by pressing the Quick Build button (or the F1 key on your keyboard)

Questions1 What do you notice with the Table of Contents the first time you

compile your document?

2 Rebuild the document. Is the problem with the Table of Contentsfixed now?

3 Then, change the document class to report and rebuild. Whatdifferences do you notice?

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 20 /78

Page 21: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Document class optional arguments

The built-in document classes provided by LATEX can be customized atwill, by using optional arguments

All optional arguments are placed in square brackets ([ ]) andseparated (if we have more than one) by commas; in\documentclass (and in most other commands) the optionalarguments are placed before the compulsory arguments

Paper size

a4paper

letterpaper

Example\documentclass[a4paper]report

Font size (default: 10pt)

11pt

12pt

Example\documentclass[a4paper,11pt]report

Document class optional arguments (cont’d)

One- or two-side printing

oneside (this is the default for articles and letters)

twoside (this is the default for books and reports)

Separate titlepage

notitlepage (this is the default for articles and letters)

titlepage (this is the default for books and reports)

Columns

onecolumn (this is the default)

twocolumn

Example\documentclass[a4paper,twoside,titlepage]article

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 25 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 21/78

Page 22: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Document class optional arguments

The built-in document classes provided by LATEX can be customized atwill, by using optional arguments

All optional arguments are placed in square brackets ([ ]) andseparated (if we have more than one) by commas; in\documentclass (and in most other commands) the optionalarguments are placed before the compulsory arguments

Paper size

a4paper

letterpaper

Example\documentclass[a4paper]report

Font size (default: 10pt)

11pt

12pt

Example\documentclass[a4paper,11pt]report

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 24 / 87

Document class optional arguments (cont’d)

One- or two-side printing

oneside (this is the default for articles and letters)

twoside (this is the default for books and reports)

Separate titlepage

notitlepage (this is the default for articles and letters)

titlepage (this is the default for books and reports)

Columns

onecolumn (this is the default)

twocolumn

Example\documentclass[a4paper,twoside,titlepage]article

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 22/78

Page 23: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Page numbering and headingsThe command \pagestyle controls page numbering and headings; ittakes one argument and should be placed in the preamble

Page style argument options

plain, prints page numbers and no headings (this is the default)

empty, prints neither page numbers nor headings

headings, prints page numbers and headings from the sections

myheadings, prints page numbers and custom headings

Example\documentclass[11pt]article

\pagestyleheadings

\begindocument...

Note

Similarly, the command \thispagestyle applies one of these options to asingle page; it is placed inside the document

Special characters

The following symbols are reserved characters that have a special meaning,so if you would add them in your source file they will not print:# $ % ^ & ~ \If you want to print one of these symbols you have to type\# \$ \% \^ \& \ \ \ \~ \textbackslash

Note

Most of the symbols are simply preceded by a \\ˆ and \˜ need also to be followed by curly brackets

The backslash cannot be preceded by another backslash (\\) as thisgenerates a new line; instead we type \textbackslash

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 27 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 23 /78

Page 24: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Page numbering and headingsThe command \pagestyle controls page numbering and headings; ittakes one argument and should be placed in the preamble

Page style argument options

plain, prints page numbers and no headings (this is the default)

empty, prints neither page numbers nor headings

headings, prints page numbers and headings from the sections

myheadings, prints page numbers and custom headings

Example\documentclass[11pt]article

\pagestyleheadings

\begindocument...

Note

Similarly, the command \thispagestyle applies one of these options to asingle page; it is placed inside the document

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 26 / 87

Special characters

The following symbols are reserved characters that have a special meaning,so if you would add them in your source file they will not print:# $ % ^ & ~ \If you want to print one of these symbols you have to type\# \$ \% \^ \& \ \ \ \~ \textbackslash

Note

Most of the symbols are simply preceded by a \\ˆ and \˜ need also to be followed by curly brackets

The backslash cannot be preceded by another backslash (\\) as thisgenerates a new line; instead we type \textbackslash

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 24 /78

Page 25: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Comments

The special character % indicates that whatever follows this symbol upuntil the end of the line is a comment and thus will be ignored by LATEX

ExampleThis shows % this is a comment

that comments don’t show

% this whole line is also a comment

in the final output

Emphasizing text

\textbftext typesets text in boldface

\textittext typesets text in italics

\underlinetext underlines the text

Note

It is common practise to use \emphtext, instead of \textit, whoseoperation depends on the context

typesets text in italic if its context is normal, and

typesets text in normal font if its context is italic

Example\emphEmphasizing when the context is emphasized

prints in \emphnormal font

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 29 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 25/78

Page 26: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Comments

The special character % indicates that whatever follows this symbol upuntil the end of the line is a comment and thus will be ignored by LATEX

ExampleThis shows % this is a comment

that comments don’t show

% this whole line is also a comment

in the final output

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 28 / 87

Emphasizing text

\textbftext typesets text in boldface

\textittext typesets text in italics

\underlinetext underlines the text

Note

It is common practise to use \emphtext, instead of \textit, whoseoperation depends on the context

typesets text in italic if its context is normal, and

typesets text in normal font if its context is italic

Example\emphEmphasizing when the context is emphasized

prints in \emphnormal font

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 26/78

Page 27: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Font size

In general, it is not recommended to mix font sizes within your text

If however, you need to do so you may use the following commands

In Texmaker

All of these commands take no arguments; if you want the effect tobe applied only to a specific context enclose it in curly brackets, e.g.

Normal text, \tiny then some tiny text, then normal again

Footnotes

Footnotes are created with the \footnote command

ExampleThis is a paragraph\footnoteThis is a footnote. of

normal text.

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 31 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 27/78

Page 28: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Font size

In general, it is not recommended to mix font sizes within your text

If however, you need to do so you may use the following commands

In Texmaker

All of these commands take no arguments; if you want the effect tobe applied only to a specific context enclose it in curly brackets, e.g.

Normal text, \tiny then some tiny text, then normal again

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 30 / 87

Footnotes

Footnotes are created with the \footnote command

ExampleThis is a paragraph\footnoteThis is a footnote. of

normal text.

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 28/78

Page 29: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Quotation marks

You should NOT use the '' (double quote symbol) for quotation marksas you would on a typewriter

In publishing there are special opening and closing quotation marks.In LATEX, use two `(grave accent) for opening quotation marks andtwo '(vertical quote) for closing quotation marks

For single quotes you use just one of each

Example``double quote'' and `single

quote'

Cross references

The command \labelmarker creates a non-printable label

The command \refmarker inserts the number of the section,subsection, figure, table, or theorem after which the corresponding\label command was issued

The command \pagerefmarker prints the page number of thepage where the \label command occurred

Example. . .\subsectionA random subsectionThis is the text we would like to refer to later, so let’s add a label.\labelmytext. . .\subsectionAnother subsectionAs I mentioned in section \refmytext on page \pagerefmytext . . .

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 33 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 29/78

Page 30: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Quotation marks

You should NOT use the '' (double quote symbol) for quotation marksas you would on a typewriter

In publishing there are special opening and closing quotation marks.In LATEX, use two `(grave accent) for opening quotation marks andtwo '(vertical quote) for closing quotation marks

For single quotes you use just one of each

Example``double quote'' and `single

quote'

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 32 / 87

Cross references

The command \labelmarker creates a non-printable label

The command \refmarker inserts the number of the section,subsection, figure, table, or theorem after which the corresponding\label command was issued

The command \pagerefmarker prints the page number of thepage where the \label command occurred

Example. . .\subsectionA random subsectionThis is the text we would like to refer to later, so let’s add a label.\labelmytext. . .\subsectionAnother subsectionAs I mentioned in section \refmytext on page \pagerefmytext . . .

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 30/78

Page 31: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Lists

There are three environments for creating lists

enumerate for numbered lists

itemize for bulleted lists

description for description lists

Within a list, each item starts with the \item command.

Example\beginenumerate

\item First item on my list

\item Second item on my list

Note that one item can span

multiple paragraphs

\endenumerate

Customizing a list’s items

The command \item takes an optional argument which replaces theitem’s default bullet or number with another symbol or number

Example\beginitemize

\item First item

\item Second item

\item[-] Third item, with dash not

bullet

\enditemize

Example\begindescription

\item[Stupid] things will not become

smart because they are in a list.

\item[Smart] things, though, can be

presented beautifully in a list.

\enddescription

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 35 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 31/78

Page 32: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Lists

There are three environments for creating lists

enumerate for numbered lists

itemize for bulleted lists

description for description lists

Within a list, each item starts with the \item command.

Example\beginenumerate

\item First item on my list

\item Second item on my list

Note that one item can span

multiple paragraphs

\endenumerate

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 34 / 87

Customizing a list’s items

The command \item takes an optional argument which replaces theitem’s default bullet or number with another symbol or number

Example\beginitemize

\item First item

\item Second item

\item[-] Third item, with dash not

bullet

\enditemize

Example\begindescription

\item[Stupid] things will not become

smart because they are in a list.

\item[Smart] things, though, can be

presented beautifully in a list.

\enddescription

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 32/78

Page 33: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Paragraph alignment

There are three environments for aligning paragraphs

flushleft for left-aligned paragraphs

flushright for right-aligned paragraphs

center for centered paragraphs

By default, LATEX aligns paragraphs both on the left and on the right, byexpanding/shrinking spaces between words universally within each line

Quotes

You can quote text from another source (book, article, etc) by

The quote environment, for single-paragraph quotes

The quotation environment, for multiple-paragraph quotes

ExampleA typographical rule of thumb

for the line length is:

\beginquote

On average, no line should be

longer than 66 characters.

\endquote

This is why \LaTeX\ pages have

such large borders by default

and also why multicolumn print

is used in newspapers.

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 37 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 33/78

Page 34: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Paragraph alignment

There are three environments for aligning paragraphs

flushleft for left-aligned paragraphs

flushright for right-aligned paragraphs

center for centered paragraphs

By default, LATEX aligns paragraphs both on the left and on the right, byexpanding/shrinking spaces between words universally within each line

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 36 / 87

Quotes

You can quote text from another source (book, article, etc) by

The quote environment, for single-paragraph quotes

The quotation environment, for multiple-paragraph quotes

ExampleA typographical rule of thumb

for the line length is:

\beginquote

On average, no line should be

longer than 66 characters.

\endquote

This is why \LaTeX\ pages have

such large borders by default

and also why multicolumn print

is used in newspapers.

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 34/78

Page 35: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Accented characters

In LATEX accented characters are produced byusing commands like \`o

I It starts with a backslash (\)I Followed by a symbol that indicates the accent

to be placed on our character (e.g. `)I Followed by the letter on which to place the

accent, normally enclosed withing curlybruckets

Exercise

Task

Generate a numbered list of three or more items of your choice

Add a nested enumerated list, consisting of two items, under the firstitem of the outer list

Add a label (with the command \label) on the second item of yourinner list

Create a new paragraph right after the end of the lists above andrefer (using the command \ref) to the item you labeled above

Questions1 How are the nested lists numbered?

2 Is the item you refered to numbered correctly?

3 How many times did you need to compile to get the reference right?

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 39 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 35/78

Page 36: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Accented characters

In LATEX accented characters are produced byusing commands like \`o

I It starts with a backslash (\)I Followed by a symbol that indicates the accent

to be placed on our character (e.g. `)I Followed by the letter on which to place the

accent, normally enclosed withing curlybruckets

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 38 / 87

Exercise

Task

Generate a numbered list of three or more items of your choice

Add a nested enumerated list, consisting of two items, under the firstitem of the outer list

Add a label (with the command \label) on the second item of yourinner list

Create a new paragraph right after the end of the lists above andrefer (using the command \ref) to the item you labeled above

Questions1 How are the nested lists numbered?

2 Is the item you refered to numbered correctly?

3 How many times did you need to compile to get the reference right?

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 36/78

Page 37: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Extending LATEX using packages

LATEX provides commands and environment to achieve the mostcommon things

However, some problems cannot be solved by basic LATEX

In such cases, we can extend the functionality by using packages

A package is a file containing extra LATEX commands andprogramming which add new styling features or modify those alreadyexisting

Package files all end with .sty

You can add a package to a document by calling the followingcommand in the preamble: \usepackage[options]package

I package is a the name of the package we want to useI options is a list of optional parameters to the package

Installing new packages

Many packages come pre-installed with Miktex. If you require a packagenot already installed, you may either:

install the package through Miktex’s Package ManagerI Miktex will automatically install it for you if you have this option

enabled

or download the package from the CTAN search page to the directorywhere your source file is located

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 42 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 37/78

Page 38: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Extending LATEX using packages

LATEX provides commands and environment to achieve the mostcommon things

However, some problems cannot be solved by basic LATEX

In such cases, we can extend the functionality by using packages

A package is a file containing extra LATEX commands andprogramming which add new styling features or modify those alreadyexisting

Package files all end with .sty

You can add a package to a document by calling the followingcommand in the preamble: \usepackage[options]package

I package is a the name of the package we want to useI options is a list of optional parameters to the package

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 41 / 87

Installing new packages

Many packages come pre-installed with Miktex. If you require a packagenot already installed, you may either:

install the package through Miktex’s Package ManagerI Miktex will automatically install it for you if you have this option

enabled

or download the package from the CTAN search page to the directorywhere your source file is located

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 38/78

Page 39: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Example PackagesLine spacing

The package setspace provides commands for setting the spacingbetween lines

It provides three commands:\singlespacing \onehalfspacing \doublespacingThe package can also take options (in \usepackage)singlespacing, onehalfspacing, and doublespacing to set thespacing for the whole document

Example

one-and-half spacing anytime, by issuing one of the above commands.

\documentclassarticle

\usepackagesetspace

\begindocument

This paragraph will be typeset as normal, in single space.

\doublespacing

All paragraphs from now on will be in doublespace. I can switch back tosingle or\enddocument

Example PackagesChanging the page layout

the package geometry allows you to change the size of the page, themargins, the orientation, etc.

the package fancyhdr provides commands to customize the headersand footers of the document

the package multicol allows you to typeset text in multiple columns(up to 10) and enables you to switch between any (permitted)number of columns at will

the package longtable can be used to create tables than span morethan one page

. . .

Note

An enormous number of packages can be found on the ComprehensiveTeX Archive Network (CTAN)http://www.ctan.org

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 44 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 39/78

Page 40: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Example PackagesLine spacing

The package setspace provides commands for setting the spacingbetween lines

It provides three commands:\singlespacing \onehalfspacing \doublespacingThe package can also take options (in \usepackage)singlespacing, onehalfspacing, and doublespacing to set thespacing for the whole document

Example\documentclassarticle

\usepackagesetspace

\begindocument

This paragraph will be typeset as normal, in single space.

\doublespacing

All paragraphs from now on will be in doublespace. I can switch back to single or one-and-half spacing anytime, by issuing one of the above commands.

\enddocument

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 43 / 87

Example PackagesChanging the page layout

the package geometry allows you to change the size of the page, themargins, the orientation, etc.

the package fancyhdr provides commands to customize the headersand footers of the document

the package multicol allows you to typeset text in multiple columns(up to 10) and enables you to switch between any (permitted)number of columns at will

the package longtable can be used to create tables than span morethan one page

. . .

Note

An enormous number of packages can be found on the ComprehensiveTeX Archive Network (CTAN)http://www.ctan.org

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 40/78

Page 41: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Example PackagesTypesetting greek in LATEX

The package greektex allows you to typeset greek in LATEX

Add the package in the preamble: \usepackagegreektexThen simply type in greek

Before typing in greek for the first time, configure Texmaker andWindows to store greek characters correctly! (see next slides)

Note

Unfortunately, the greektex package is not available in Miktex’s Package Manager. It must be downloaded from:http://ctan.org/tex-archive/fonts/greek/greektex

You will find installation instructions in the above site.

Creating tablesThe environment tabular is used to create tables. It is formatted as\begintabulartable spectable spec is a list of options that define the format of the table:

l specifies a left-aligned column

r specifies a right-aligned column

c specifies a centered column

pwidth specifies a column of given width, where the text will wraparound if it doesn’t fit

| specifies a vertical line

Within a tabular environment

& jumps to the next column

\\ starts a new line

\hline inserts a horizontal line

\clinei − j inserts a horizontal line that spans columns i through j

\vline draws a vertical line with the height of the row

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 47 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 41/78

Page 42: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Example PackagesTypesetting greek in LATEX

The package greektex allows you to typeset greek in LATEX

Add the package in the preamble: \usepackagegreektexThen simply type in greek

Before typing in greek for the first time, configure Texmaker andWindows to store greek characters correctly! (see next slides)

Note

Unfortunately, the greektex package is not available in Miktex’s PackageManager. It must be downloaded from:http://ctan.org/tex-archive/fonts/greek/greektex

You will find installation instructions in the above site, but since these arenot up-to-date, I have uploaded my own instructions herehttp://www.eng.ucy.ac.cy/manolisc/greektex-installation-Miktex2.9.pdf

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 45 / 87

Creating tablesThe environment tabular is used to create tables. It is formatted as\begintabulartable spectable spec is a list of options that define the format of the table:

l specifies a left-aligned column

r specifies a right-aligned column

c specifies a centered column

pwidth specifies a column of given width, where the text will wraparound if it doesn’t fit

| specifies a vertical line

Within a tabular environment

& jumps to the next column

\\ starts a new line

\hline inserts a horizontal line

\clinei − j inserts a horizontal line that spans columns i through j

\vline draws a vertical line with the height of the row

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 42/78

Page 43: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Table example

Example\begintabularlp3cmc|r

Item & Description & Quantity & Price \\

\hline

Belkin F5D7632 & Belkin ADSL Wireless G Modem Router F5D7632 for BT Line

& 1 & 9.59\\

&&&\\

\hline

Total & & & 9.59

\endtabular

Text spanning multiple columns

The command \multicolumncolspostext can be used inside atable to insert text that spans multiple columns

cols is the number of columns the text will span

pos specifies the alignment within the current multi-columnI it can take values: r, l, c, pwidth

text is the text to be inserted in the multi-column

Example\begintabularl|c|r

Item & Quantity & Price \\

\hline

F5D7632 & 1 & 9.59\\

\hline

\multicolumn2cTotal \vline & 9.59

\endtabular

Item Quantity Price

F5D7632 1 9.59

Total 9.59

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 49 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 43/78

Page 44: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Table example

Example\begintabularlp3cmc|r

Item & Description & Quantity & Price \\

\hline

Belkin F5D7632 & Belkin ADSL Wireless G Modem Router F5D7632 for BT Line

& 1 & 9.59\\

&&&\\

\hline

Total & & & 9.59

\endtabular

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 48 / 87

Text spanning multiple columns

The command \multicolumncolspostext can be used inside atable to insert text that spans multiple columns

cols is the number of columns the text will span

pos specifies the alignment within the current multi-columnI it can take values: r, l, c, pwidth

text is the text to be inserted in the multi-column

Example\begintabularl|c|r

Item & Quantity & Price \\

\hline

F5D7632 & 1 & 9.59\\

\hline

\multicolumn2cTotal \vline & 9.59

\endtabular

Item Quantity Price

F5D7632 1 9.59

Total 9.59

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 44/78

Page 45: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Table positioningThe tabular environment can also take an optional argument\begintabular[pos]table spec which specifies the verticalposition of the table relative to the baseline of the surrounding text

t aligns the text with the top of the table

b aligns the text with the bottom of the table

c aligns the text with the center of the table

ExampleThe bill:

\begintabular[c]|lc|r|

\hline

Item & Quantity & Price \\

\hline

Belkin F5D7632 & 1 & 9.59\\

NetGear WGR614 & 1 & 17.95\\

\hline

Total & & 27.54\\

\hline

\endtabular

Texmaker tabular wizard

Texmaker provides a wizard to assist you creating tables

Click on the menu Wizard and choose Quick Tabular

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 51 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 45/78

Page 46: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Table positioningThe tabular environment can also take an optional argument\begintabular[pos]table spec which specifies the verticalposition of the table relative to the baseline of the surrounding text

t aligns the text with the top of the table

b aligns the text with the bottom of the table

c aligns the text with the center of the table

ExampleThe bill:

\begintabular[c]|lc|r|

\hline

Item & Quantity & Price \\

\hline

Belkin F5D7632 & 1 & 9.59\\

NetGear WGR614 & 1 & 17.95\\

\hline

Total & & 27.54\\

\hline

\endtabular

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 50 / 87

Texmaker tabular wizard

Texmaker provides a wizard to assist you creating tables

Click on the menu Wizard and choose Quick Tabular

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 46/78

Page 47: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Floating bodies

Tables and figures normally cannot be broken across pages

Starting a new page every time a table or figure does not fit in thecurrent page, leaves partially empty pages which is ugly! (see MSWord!)

LATEX floats any table or figure that does not fit on the current pageto a later page, while filling the current page with body text

There are two environments for floating bodies\begintable[...] and \beginfigure[...]The optional parameter takes one or more (in order of preference) ofthe following options:

I t to place the item at the top of the pageI b to place the item at the bottom of the pageI h to place the item right hereI p to place the item on a special “floats” page

By adding a ! as a first argument in the list above tries to force yourrecommendation

Floating bodies – Example

Example\begintable[htbp]

\begincenter

\begintabular||c|l||

\hline

option & meaning \\

\hline

h & here on the page \\

b & bottom of a page \\

t & top of a page \\

p & floating page \\

\hline

\endtabular

\endcenter

\captionTable-Figure Destinations

\labeltb:loc

\endtable

The \captioncommand defines acaption for the float

LATEX automaticallyadds the word“Table” or “Figure”and a number infront of the caption

Using the commands\listoffiguresand \listoftablesLATEX automaticallygenerates a list offigures and tablesrespectively

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 53 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 47/78

Page 48: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Floating bodies

Tables and figures normally cannot be broken across pages

Starting a new page every time a table or figure does not fit in thecurrent page, leaves partially empty pages which is ugly! (see MSWord!)

LATEX floats any table or figure that does not fit on the current pageto a later page, while filling the current page with body text

There are two environments for floating bodies\begintable[...] and \beginfigure[...]The optional parameter takes one or more (in order of preference) ofthe following options:

I t to place the item at the top of the pageI b to place the item at the bottom of the pageI h to place the item right hereI p to place the item on a special “floats” page

By adding a ! as a first argument in the list above tries to force yourrecommendation

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 52 / 87

Floating bodies – Example

Example\begintable[htbp]

\begincenter

\begintabular||c|l||

\hline

option & meaning \\

\hline

h & here on the page \\

b & bottom of a page \\

t & top of a page \\

p & floating page \\

\hline

\endtabular

\endcenter

\captionTable-Figure Destinations

\labeltb:loc

\endtable

The \captioncommand defines acaption for the float

LATEX automaticallyadds the word“Table” or “Figure”and a number infront of the caption

Using the commands\listoffiguresand \listoftablesLATEX automaticallygenerates a list offigures and tablesrespectively

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 48/78

Page 49: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Including graphics

Load the graphicx package in the preamble:\usepackagegraphicxTo include a picture in your document use\includegraphics[key=value,...]filename

I filename is the filename (including the path) of the pictureI The optional parameter accepts a comma separated list of keys and

associated values. Available keys include:width, height, angle, scale

The picture may (optionally) be enclosed in a figure environment

Example\beginfigure

\centering

\includegraphics[angle=90, width=0.5\textwidth]mypicture

\captionThis is my figure.

\endfigure

Typesetting mathematics

Mathematics can be typeset in two styles:

in text style, where maths is printed inline within a paragraph

in display style, where maths is printed as a separate paragraph

The inline mode is achieved by enclosing the maths in $ ...$

ExampleWithin the current paragraph

I will typeset some maths in

\emphtext style, as follows:

$a + b = 5$; notice that the

math occurs inline; notice also

that when typesetting maths (in

either style) all spaces are

being ignored!

Within the current paragraph I willtypeset some maths in text style,as follows: a+ b = 5; notice thatthe math occurs inline; notice alsothat when typesetting maths (ineither style) all spaces are beingignored!

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 56 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 49/78

Page 50: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Including graphics

Load the graphicx package in the preamble:\usepackagegraphicxTo include a picture in your document use\includegraphics[key=value,...]filename

I filename is the filename (including the path) of the pictureI The optional parameter accepts a comma separated list of keys and

associated values. Available keys include:width, height, angle, scale

The picture may (optionally) be enclosed in a figure environment

Example\beginfigure

\centering

\includegraphics[angle=90, width=0.5\textwidth]mypicture

\captionThis is my figure.

\endfigure

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 54 / 87

Typesetting mathematics

Mathematics can be typeset in two styles:

in text style, where maths is printed inline within a paragraph

in display style, where maths is printed as a separate paragraph

The inline mode is achieved by enclosing the maths in $ ...$

ExampleWithin the current paragraph

I will typeset some maths in

\emphtext style, as follows:

$a + b = 5$; notice that the

math occurs inline; notice also

that when typesetting maths (in

either style) all spaces are

being ignored!

Within the current paragraph I willtypeset some maths in text style,as follows: a+ b = 5; notice thatthe math occurs inline; notice alsothat when typesetting maths (ineither style) all spaces are beingignored!

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 50/78

Page 51: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Mathematics in display style

There are two ways to typeset maths in display style

using the commands \[...\] where equations are by defaultnon-numbered

using the environment equation where equations are by defaultnumbered

ExampleTypesetting maths

in display style

\[ a*b=6 \]

is similar to

\beginequation

a*b=6 \labeleq:atimesb

\endequation

As shown, in Equation

(\refeq:atimesb) above, bla

bla bla

Typesetting maths in display style

a ∗ b = 6

is similar to

a ∗ b = 6 (1)

As shown, in Equation (1) above,bla bla bla

Math mode vs text mode

In math mode:

More than one spaces and single line breaks are ignoredI if you want to add custom spaces use \quad for a single space and\qquad for a double space

Empty lines are not allowed

Letters are considered as variable names and are typeset in italicsI if you want to typeset text within math mode use the \textrm...

command

Example$x^2 \geq 0\qquad \textrmfor

all x\in\mathbfR$

x2 ≥ 0 for all x ∈ R

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 58 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 51/78

Page 52: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Mathematics in display style

There are two ways to typeset maths in display style

using the commands \[...\] where equations are by defaultnon-numbered

using the environment equation where equations are by defaultnumbered

ExampleTypesetting maths

in display style

\[ a*b=6 \]

is similar to

\beginequation

a*b=6 \labeleq:atimesb

\endequation

As shown, in Equation

(\refeq:atimesb) above, bla

bla bla

Typesetting maths in display style

a ∗ b = 6

is similar to

a ∗ b = 6 (1)

As shown, in Equation (1) above,bla bla bla

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 57 / 87

Math mode vs text mode

In math mode:

More than one spaces and single line breaks are ignoredI if you want to add custom spaces use \quad for a single space and\qquad for a double space

Empty lines are not allowed

Letters are considered as variable names and are typeset in italicsI if you want to typeset text within math mode use the \textrm...

command

Example$x^2 \geq 0\qquad \textrmfor

all x\in\mathbfR$

x2 ≥ 0 for all x ∈ R

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 52/78

Page 53: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Greek letters in math mode

Lowercase greek letters are entered as\alpha, \beta, \gamma, . . .

Uppercase greek letters are entered as\Alpha, \Beta, \Gamma, . . .

Example$ \chi + \Psi - \Omega = \xi/2 $

χ+ Ψ− Ω = ξ/2

Exponents, Superscripts and Subscripts

Exponents and superscripts are achieved with the ^ symbol

Subscripts are achieved with the symbol

^ and act only on the next character, so if you want a command toaffect several characters, you have to group them together using curlybraces: ...

Example\[ x^\alpha+5 i = \sum j=1^m y j \]

xα+5i =

m∑j=1

yj

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 60 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 53/78

Page 54: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Greek letters in math mode

Lowercase greek letters are entered as\alpha, \beta, \gamma, . . .

Uppercase greek letters are entered as\Alpha, \Beta, \Gamma, . . .

Example$ \chi + \Psi - \Omega = \xi/2 $

χ+ Ψ− Ω = ξ/2

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 59 / 87

Exponents, Superscripts and Subscripts

Exponents and superscripts are achieved with the ^ symbol

Subscripts are achieved with the symbol

^ and act only on the next character, so if you want a command toaffect several characters, you have to group them together using curlybraces: ...

Example\[ x^\alpha+5 i = \sum j=1^m y j \]

xα+5i =

m∑j=1

yj

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 54/78

Page 55: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

More mathematical symbols

\cdot produces a single centered dot (multiplication)

\cdots produces three centered dots

\ldots produces three low dots

\sum produces the sum

\prod produces the product

\lim produces the limit

Example\[ x 1 + x 2 + \ldots +

x n= \sum i=1^n x i \]

\[ x 1 \cdot x 2 \cdots x n=

\prod i=1^n x i \]

x1 + x2 + . . .+ xn =n∑

i=1

xi

x1 · x2 · · · xn =n∏

i=1

xi

More mathematical symbols

\binom takes two arguments and typesets the binomial

\int produces the integral

\sqrt produces the square root of its argumentI takes also an optional argument [n] to define the n-th root

\frac takes two arguments and produces their fraction

Example\[ \int 0^\frac\pi2x

\mathrmdx

\qquad \binomnm

\qquad \sqrt[3]125\]

∫ π2

0xdx

(n

m

)3√

125

A list of available mathematical symbols can be found athttp://amath.colorado.edu/documentation/LaTeX/Symbols.pdf

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 62 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 55/78

Page 56: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

More mathematical symbols

\cdot produces a single centered dot (multiplication)

\cdots produces three centered dots

\ldots produces three low dots

\sum produces the sum

\prod produces the product

\lim produces the limit

Example\[ x 1 + x 2 + \ldots +

x n= \sum i=1^n x i \]

\[ x 1 \cdot x 2 \cdots x n=

\prod i=1^n x i \]

x1 + x2 + . . .+ xn =n∑

i=1

xi

x1 · x2 · · · xn =n∏

i=1

xi

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 61 / 87

More mathematical symbols

\binom takes two arguments and typesets the binomial

\int produces the integral

\sqrt produces the square root of its argumentI takes also an optional argument [n] to define the n-th root

\frac takes two arguments and produces their fraction

Example\[ \int 0^\frac\pi2x

\mathrmdx

\qquad \binomnm

\qquad \sqrt[3]125\]

∫ π2

0xdx

(n

m

)3√

125

A list of available mathematical symbols can be found athttp://amath.colorado.edu/documentation/LaTeX/Symbols.pdf

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 56/78

Page 57: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Left and right delimiters

If you put \left in front of an opening delimiter and \right in frontof a closing delimiter, LATEX will automatically determine the correctsize of the delimiter

You must close every \left with a corresponding \rightI If you don’t want anything on the right, use the invisible “\right.”

Example$1 + \left(

\frac11-x^2\right)^3

\qquad \left\

\frac11-x^2\right.$

1 +(

11−x2

)3 1

1−x2

Arrays and matricesTo typeset arrays, use the array environment. It works similar to thetabular environment

Example\[ \mathbfX= \left(

\beginarrayccc

x 1 & x 2 & \ldots \\

x 3 & x 4 & \ldots \\

\vdots & \vdots & \ddots

\endarray\right) \]

Example\[ |x| = \left\

\beginarrayrl

-x & \textrmif x < 0,\\

0 & \textrmif x = 0,\\

x & \textrmif x > 0.

\endarray\right. \]

X =

x1 x2 . . .x3 x4 . . ....

.... . .

|x | =

−x if x < 0,

0 if x = 0,x if x > 0.

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 64 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 57/78

Page 58: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Left and right delimiters

If you put \left in front of an opening delimiter and \right in frontof a closing delimiter, LATEX will automatically determine the correctsize of the delimiter

You must close every \left with a corresponding \rightI If you don’t want anything on the right, use the invisible “\right.”

Example$1 + \left(

\frac11-x^2\right)^3

\qquad \left\

\frac11-x^2\right.$

1 +(

11−x2

)3 1

1−x2

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 63 / 87

Arrays and matricesTo typeset arrays, use the array environment. It works similar to thetabular environment

Example\[ \mathbfX= \left(

\beginarrayccc

x 1 & x 2 & \ldots \\

x 3 & x 4 & \ldots \\

\vdots & \vdots & \ddots

\endarray\right) \]

Example\[ |x| = \left\

\beginarrayrl

-x & \textrmif x < 0,\\

0 & \textrmif x = 0,\\

x & \textrmif x > 0.

\endarray\right. \]

X =

x1 x2 . . .x3 x4 . . ....

.... . .

|x | =

−x if x < 0,

0 if x = 0,x if x > 0.

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 58/78

Page 59: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Defining theorem environments

With the \newtheorem command in the preamble you define a newenvironment that looks like a theorem (theorem, lemma, axiom, etc.)

The syntax is: \newtheoremname[counter]text[section]I name is a the name of the environment used in the LATEX source file to

identify the “theorem” (e.g. lem for typesetting Lemmas)I text is the text that will be printed in front of the “theorem” in the

output file (e.g. Lemma)I counter (optional) is the name of a previously declared “theorem” and

makes the new “theorem” to be numbered in the same sequenceI section (optional) specifies the sectional unit within which the

“theorem” should get its numbers

Using theorems

After defining a new “theorem”, we use it like this

\beginname[title]

This is my interesting theorem

\endname

I name is a the name of the environment we created using the\newtheorem command

I title (optional) gives a title to the particular theorem

Example\documentclassarticle

\newtheoremlemLemma[section]

...

\begindocument

...

\beginlem[Manolis’ new lemma]

Typesetting theorems in \LaTeX is easy!

\endlem

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 66 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 59/78

Page 60: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Defining theorem environments

With the \newtheorem command in the preamble you define a newenvironment that looks like a theorem (theorem, lemma, axiom, etc.)

The syntax is: \newtheoremname[counter]text[section]I name is a the name of the environment used in the LATEX source file to

identify the “theorem” (e.g. lem for typesetting Lemmas)I text is the text that will be printed in front of the “theorem” in the

output file (e.g. Lemma)I counter (optional) is the name of a previously declared “theorem” and

makes the new “theorem” to be numbered in the same sequenceI section (optional) specifies the sectional unit within which the

“theorem” should get its numbers

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 65 / 87

Using theorems

After defining a new “theorem”, we use it like this

\beginname[title]

This is my interesting theorem

\endname

I name is a the name of the environment we created using the\newtheorem command

I title (optional) gives a title to the particular theorem

Example\documentclassarticle

\newtheoremlemLemma[section]

...

\begindocument

...

\beginlem[Manolis’ new lemma]

Typesetting theorems in \LaTeX is easy!

\endlem

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 60/78

Page 61: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Exercise

Task

Generate the mathematical formula you see below

f (n) =

n/2 if n is even−(n + 1)/2 if n is odd

Visithttp://amath.colorado.edu/documentation/LaTeX/Symbols.pdf

and find out how to typeset the following

Λ

(n⋂

j=1

Oj

)⊂

n⋂j=1

Λ(Oj)

Where to go next

Tobias Oetiker, Hubert Partl, Irene Hyna and Elisabeth Schlegl. The(Not So) Short Guide to LATEX2e: LATEX2e in 157 Minutes. 2011,Technical report.http://tobi.oetiker.ch/lshort/lshort.pdf

Peter Flynn A beginner’s introduction to typesetting with LATEX (FifthEdition). 2011

Leslie Lamport. LATEX: A Document Preparation System.Addison-Wesley, Reading, Massachusetts, second edition, 1994, ISBN0-201-52983-1.

Frank Mittelbach, Michel Goossens, Johannes Braams, David Carlisle,Chris Rowley. The LATEX Companion, (2nd Edition). Addison-Wesley,Reading, Massachusetts, 2004, ISBN 0-201-36299-6.

The Comprehensive LATEX Symbol Listhttp://ctan.org/tex-archive/info/symbols/comprehensive

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 68 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 61/78

***Also see MathType

Page 62: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Exercise

Task

Generate the mathematical formula you see below

f (n) =

n/2 if n is even−(n + 1)/2 if n is odd

Visithttp://amath.colorado.edu/documentation/LaTeX/Symbols.pdf

and find out how to typeset the following

Λ

(n⋂

j=1

Oj

)⊂

n⋂j=1

Λ(Oj)

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 67 / 87

Where to go next

Tobias Oetiker, Hubert Partl, Irene Hyna and Elisabeth Schlegl. The(Not So) Short Guide to LATEX2e: LATEX2e in 157 Minutes. 2011,Technical report.http://tobi.oetiker.ch/lshort/lshort.pdf

Peter Flynn A beginner’s introduction to typesetting with LATEX (FifthEdition). 2011

Leslie Lamport. LATEX: A Document Preparation System.Addison-Wesley, Reading, Massachusetts, second edition, 1994, ISBN0-201-52983-1.

Frank Mittelbach, Michel Goossens, Johannes Braams, David Carlisle,Chris Rowley. The LATEX Companion, (2nd Edition). Addison-Wesley,Reading, Massachusetts, 2004, ISBN 0-201-36299-6.

The Comprehensive LATEX Symbol Listhttp://ctan.org/tex-archive/info/symbols/comprehensive

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 62/78

Page 63: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Appendix A

Customizing LATEX

Paragraph indents and spacing

Paragraph indentation depends on the document class in use

Occasionally you may want a paragraph to have no indentation; insuch cases you can precede the paragraph with the command\noindentIf you want to change the size of the indent of all paragraphs in yourdocument you can change the parameter \parindentThe \setlength command can be used in the preamble to specify acustom indentation length\setlength\parindentlengthSimilarly, the space between paragraphs is held in \parskip, whichcould be altered in a similar fashion as above

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 71 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 63/78

Page 64: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Appendix A

Customizing LATEX

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 70 / 87

Paragraph indents and spacing

Paragraph indentation depends on the document class in use

Occasionally you may want a paragraph to have no indentation; insuch cases you can precede the paragraph with the command\noindentIf you want to change the size of the indent of all paragraphs in yourdocument you can change the parameter \parindentThe \setlength command can be used in the preamble to specify acustom indentation length\setlength\parindentlengthSimilarly, the space between paragraphs is held in \parskip, whichcould be altered in a similar fashion as above

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 64/78

Page 65: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Customising enumerated lists

For all objects that LATEX automatically numbers (sections, theorems,etc.), there is a counter associated with it

Each counter has a default format that dictates how it is displayed

Command Example

\arabic 1, 2, 3 . . .\alph a, b, c . . .\Alph A, B, C . . .\roman i, ii, iii . . .\Roman I, II, III . . .

There are four individual counters that are associated withenumerated lists, representing the four possible levels of nesting:enumi, enumii, enumiii, enumiv

Customising enumerated lists (cont’d)

There two commands associated with a counter, e.g. \enumiI \theenumi which defines how the counter is used in cross-references,

andI \labelenumi which defines how the counter is printed in the list

You can modify the number of a list by issuing:

\renewcommand\theenumi\Romanenumi

\renewcommand\labelenumi\theenumi

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 73 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 65/78

Page 66: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Customising enumerated lists

For all objects that LATEX automatically numbers (sections, theorems,etc.), there is a counter associated with it

Each counter has a default format that dictates how it is displayed

Command Example

\arabic 1, 2, 3 . . .\alph a, b, c . . .\Alph A, B, C . . .\roman i, ii, iii . . .\Roman I, II, III . . .

There are four individual counters that are associated withenumerated lists, representing the four possible levels of nesting:enumi, enumii, enumiii, enumiv

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 72 / 87

Customising enumerated lists (cont’d)

There two commands associated with a counter, e.g. \enumiI \theenumi which defines how the counter is used in cross-references,

andI \labelenumi which defines how the counter is printed in the list

You can modify the number of a list by issuing:

\renewcommand\theenumi\Romanenumi

\renewcommand\labelenumi\theenumi

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 66/78

Page 67: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Customising itemized lists

Itemised lists are not as complex as they do not need to count

Therefore, to customise, you simply change the labels

The itemize labels for the four respective levels are accessed via:\labelitemi, \labelitemii, \labelitemiii, \labelitemivExample:\renewcommand\labelitemi\textgreater

Customising footnote numbers

By default, footnotes are numbered in Arabic

You can change footnote numbering by using the following command\renewcommand\thefootnote\alphafootnote

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 75 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 67/78

Page 68: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Customising itemized lists

Itemised lists are not as complex as they do not need to count

Therefore, to customise, you simply change the labels

The itemize labels for the four respective levels are accessed via:\labelitemi, \labelitemii, \labelitemiii, \labelitemivExample:\renewcommand\labelitemi\textgreater

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 74 / 87

Customising footnote numbers

By default, footnotes are numbered in Arabic

You can change footnote numbering by using the following command\renewcommand\thefootnote\alphafootnote

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 68/78

Page 69: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Appendix B

The AMS-LATEX bundle

The AMS-LATEX bundle

If you want to typeset (advanced) mathematics, you should useAMS-LATEX; it is a collection of packages and classes formathematical typesetting

AMS stands for the American Mathematical Society

The most commonly used package of the bundle is amsmath, whichcontains commands for typesetting maths

Other useful packages of the AMS include:I amsthm for theoremsI amssymb for mathematical symbolsI amsfont for mathematical fonts

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 78 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 69/78

Page 70: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Appendix B

The AMS-LATEX bundle

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 77 / 87

The AMS-LATEX bundle

If you want to typeset (advanced) mathematics, you should useAMS-LATEX; it is a collection of packages and classes formathematical typesetting

AMS stands for the American Mathematical Society

The most commonly used package of the bundle is amsmath, whichcontains commands for typesetting maths

Other useful packages of the AMS include:I amsthm for theoremsI amssymb for mathematical symbolsI amsfont for mathematical fonts

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 70/78

Page 71: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

The amsmath packageA sample of commands and enviroments provided by amsmath:

The multline environment allows for line breaks in equations

The align environment for aligning equations

The matrix environment and its variants for matrices

The amsthm package

As noted earlier, the command \newtheorem allows you to defineyour own theorem environmentsThe amsthm package provides the \theoremstylestyle commandwhich lets you define what the theorem is all about by picking fromthree predefined styles:

I definition fat title, roman bodyI plain fat title, italic bodyI remark italic title, roman body

Simply, put the right \theoremstyle command before defining thenew theorem environments with \newtheorem

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 80 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 71/78

Page 72: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

The amsmath packageA sample of commands and enviroments provided by amsmath:

The multline environment allows for line breaks in equations

The align environment for aligning equations

The matrix environment and its variants for matrices

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 79 / 87

The amsthm package

As noted earlier, the command \newtheorem allows you to defineyour own theorem environmentsThe amsthm package provides the \theoremstylestyle commandwhich lets you define what the theorem is all about by picking fromthree predefined styles:

I definition fat title, roman bodyI plain fat title, italic bodyI remark italic title, roman body

Simply, put the right \theoremstyle command before defining thenew theorem environments with \newtheorem

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 72/78

Page 73: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Proofs

The amsthm package also provides the proof environment

It will automatically print the end-of-proof symbol at the end of theproof

The amssymb package

The amssymb package provides a large number of mathematicalsymbols that were not available in plain LATEX

For example:

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 82 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 73/78

Page 74: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Proofs

The amsthm package also provides the proof environment

It will automatically print the end-of-proof symbol at the end of theproof

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 81 / 87

The amssymb package

The amssymb package provides a large number of mathematicalsymbols that were not available in plain LATEX

For example:

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 74/78

Page 75: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Mathematical fonts

The packages amssymb and amsfont provide mathematical fonts andfont-formatting commands

For example:

Appendix C

Dealing with Greek characters

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 85 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 75/78

Page 76: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Mathematical fonts

The packages amssymb and amsfont provide mathematical fonts andfont-formatting commands

For example:

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 83 / 87

Appendix C

Dealing with Greek characters

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 76/78

Page 77: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Dealing with greek characters in Windows

Open Control Panel

Go to Regional and Language Options

Tab Advanced

In Language for non-Unicode programs choose Greek

Dealing with greek characters in Texmaker

If you type greek characters directly in your LATEX source file, but theydon’t appear correctly, then follow these instructions:

Click on the menu Options and choose Configure Texmaker

In the tab Editor set Editor Font Encoding to ISO-8859-7

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 87 / 87

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 77/78

Page 78: Introduction to LaTeX - ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥucy.ac.cy/.../latex_slides-KyriakouVrachimis.pdf · 2020. 4. 3. · Introduction to LATEX Manolis Christodoulakis Department

Dealing with greek characters in Windows

Open Control Panel

Go to Regional and Language Options

Tab Advanced

In Language for non-Unicode programs choose Greek

Manolis Christodoulakis (UCY) Introduction to LATEX September 2012 86 / 87

Dealing with greek characters in Texmaker

If you type greek characters directly in your LATEX source file, but theydon’t appear correctly, then follow these instructions:

Click on the menu Options and choose Configure Texmaker

In the tab Editor set Editor Font Encoding to ISO-8859-7

Introduction to LaTeXStelios Vrachimis, Alexis Kyriacou 78/78


Recommended