LaTeX—A Gentle Introductionbooks.sayahna.org/ml/pdf/stmse-ltx-intro.pdf ·...

12
L A T E X L A T E X A GENTLE INTRODUCTION

Transcript of LaTeX—A Gentle Introductionbooks.sayahna.org/ml/pdf/stmse-ltx-intro.pdf ·...

Page 1: LaTeX—A Gentle Introductionbooks.sayahna.org/ml/pdf/stmse-ltx-intro.pdf · tent,beitbook,article,letter,reportandthelike. ThisiscalledL ATEX.TEXandLTEXareoftenused synonymously,butbeinformedthatthisdifferent

LATEXLATEXA GENTLE INTRODUCTION

Page 2: LaTeX—A Gentle Introductionbooks.sayahna.org/ml/pdf/stmse-ltx-intro.pdf · tent,beitbook,article,letter,reportandthelike. ThisiscalledL ATEX.TEXandLTEXareoftenused synonymously,butbeinformedthatthisdifferent

LATEX—A Gentle IntroductionCV Radhakrishnan(English: tech. notes)

© 2020 Sayahna Foundation

These electronic versions are released under the provisionsof Creative Commons Attribution ShareAlike license for freedownload and usage.

The electronic versions were generated from sources markedup in LATEX in a computer running gnu/linux operating sys-tem. pdf was typeset using XƎTEX from TEXLive 2020. Thebase font used was Linux Libertine developed by PhilippH. Poll.

Cover: Road in the Village of Baldersbrønded, a painting byL. A. Ring (1854–1933). The image is taken from WikimediaCommons and is gratefully acknowledged.

Sayahna FoundationjwRa 34, Jagathy, Trivandrum, India 695014uRl: www.sayahna.org

Page 3: LaTeX—A Gentle Introductionbooks.sayahna.org/ml/pdf/stmse-ltx-intro.pdf · tent,beitbook,article,letter,reportandthelike. ThisiscalledL ATEX.TEXandLTEXareoftenused synonymously,butbeinformedthatthisdifferent

Contents

Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Introduction . . . . . . . . . . . . 52 What is LATEX . . . . . . . . . . . . 63 Why LATEX? . . . . . . . . . . . . . 74 Semantic reasons . . . . . . . . . . 85 Technical reasons . . . . . . . . . . 96 Where to get TEX? . . . . . . . . . 10

3

Page 4: LaTeX—A Gentle Introductionbooks.sayahna.org/ml/pdf/stmse-ltx-intro.pdf · tent,beitbook,article,letter,reportandthelike. ThisiscalledL ATEX.TEXandLTEXareoftenused synonymously,butbeinformedthatthisdifferent

LATEX—A Gentle Introductionfor the Impatient

Apache,MySQL, Post-

greSQL, Django,Joomla, Dwoo,OSQA, phpBB,

Wordpress,Mediawiki

goLATEX.de

Forum

Wiki

TEXwelt.de

TEXnique.fr

Fragen &Antworten

Userblog

TEXample.net

TikZ-Galerie

Blog

Planet

PGFPlots.net

LATEX-Community

.org

Forum

Artikel-Archiv

News

TEXdoc.net

UK TEXFAQ

Blogs

TEXblog.net

TikZ.de

LATEX-Cookbook

.net

Seit 2008•68 444 Beitrage•13 715 Themen•5 532 registrierte Nutzer

Seit 2008•81 991 Beitrage•21 026 Themen•13 354 registrierte Nutzer

•115 Artikel

•240 Meldungen

Seit 2006•172 Autoren•384 Beispiele

•152 erklarte Konzepte,Befehle und Pakete

Seit 2013•1 710 Fragen•2 151 Antworten•479 registrierte Nutzer

Seit 2013•14 Autoren

•14 Autoren•59 Beispiele

•46 Blogs

2015, aufgrund Ideemit franzosischenTEX-Freunden nachder TUG Damstadt,experimentell

Ab 10/2015, soll ca. 100Beispiele aus dem LATEXCookbook zeigen, sowieCommunity-Rezepte

Amind-map diagram created with TEX.

4

Page 5: LaTeX—A Gentle Introductionbooks.sayahna.org/ml/pdf/stmse-ltx-intro.pdf · tent,beitbook,article,letter,reportandthelike. ThisiscalledL ATEX.TEXandLTEXareoftenused synonymously,butbeinformedthatthisdifferent

1 Introduction

Don Knuth

TEX is a markup based, classictypesetting system, developedby Prof. Donald Knuth of Stan-ford University in early eightiesof twentieth century. He starteddeveloping the TEX system whenhe was frustrated with the poor

typographical quality and aesthetics of the galleyproofs of his monumental volumes, The Art of Com-puter Programming, provided by his publisher. Hisintention was to write a system to create the besttypeset books in the world. Indeed, he succeededin this mission with the release of the final bugfree version of TEX in 1984 which he began to worknearly a decade ago.

TEX is a free software, maybe theearliest of the kind published evenbefore the advent of Free Soft-ware Foundation. The free soft-ware means that any user can use,study, modify, copy and distributethe program at ones will. It is alsoavailable for free without paying any money. Andtherefore, thousands of academics around the worldstarted using TEX system, suggested improvementsand modified the system, developed supporting li-braries, often called packages in TEX’s parlance,added more and more free fonts, extended the sys-tem to different operating systems and computersystems, extended TEX to accept Unicode input,non-Latin scripts, and in short became the supremetypesetting engine of choice of academics.

Page 6: LaTeX—A Gentle Introductionbooks.sayahna.org/ml/pdf/stmse-ltx-intro.pdf · tent,beitbook,article,letter,reportandthelike. ThisiscalledL ATEX.TEXandLTEXareoftenused synonymously,butbeinformedthatthisdifferent

2 What is LATEX

L. Lamport

TEX is the name of the systemand also the name of compiler(or the program) that does thetypesetting job. TEX also has apowerful, highly programmablemacro language that can simu-late any mainstream language.Knuth used TEX’s native primitive

commands coupled with quite a few functions hewrote to typeset his book series. This combinationof macros and native commands is called plain for-mat. The macros are not generic in nature, meaning,one has to write one’s own functions to typeset owncontent. To circumvent this problem, Leslie Lam-port developed a set of macro libraries with whichhe defined all the functions needed to typeset con-tent, be it book, article, letter, report and the like.This is called LATEX. TEX and LATEX are often usedsynonymously, but be informed that this differentdoes exist.

√2

√3

√4√

5√

6

√7

√8

√9√

10 √11 √

12√

13

√14

√15

√16

√17

√18

√19

√20

√21

√22

√23

√24

√25

√26√

27√28

√29

√30

√31

√32

√33

√34

√35

√36

√37√

38√

39√

40 √41 √

42 √43

√44

√45

√46

√47

√48

√49

√50

√51

√52

√53

√54

√55

√56

√57

√58

√59

√60

√61

√62

√63

√64

√65

√66

√67√

68√69√

70√71

√72

√73

√74

√75

√76

√77

√78

√79

√80

√81

√82

√83

√84

√85

√86√

87

√2

√3

√4√

5√

6

√7

√8

√9√

10 √11 √

12√

13

√14

√15

√16

√17

√18

√19

√20

√21

√22

√23

√24

√25

√26√

27√28

√29

√30

√31

√32

√33

√34

√35

√36

√37√

38√

39

√2

√3

√4√

5√

6

√7

√8

√9√

10 √11 √

12√

13

√14

√15

√16

√1

A helix diagram.

The academics around the world do use LATEX whenthey say that they use TEX. Thousands of support-ing macro libraries were written by informed usersaround the world and distributed for free amongusers. Thus the system has now grown to roughlyseven Gigs of software if you want to have a com-plete installation of TEX typesetting system. Such isthe vibrant nature of the system and the communityof users as well.

Page 7: LaTeX—A Gentle Introductionbooks.sayahna.org/ml/pdf/stmse-ltx-intro.pdf · tent,beitbook,article,letter,reportandthelike. ThisiscalledL ATEX.TEXandLTEXareoftenused synonymously,butbeinformedthatthisdifferent

3 Why LATEX?

The users might be perplexed to think why we shouldwe go to a four decade old typesetting system toprocess present day documents when we have mod-ern graphical driven word processors and type-setting systems? There are several reasons for thesame. First, let us see the historical reasons.

• TEX was developed by an academic for academics,hence, the system understands what an aca-demic or researcher is looking forward to.

• LATEX has become the de facto standard of mathand technical communication in the academicworld. So, also, the word processors and frame-works like Wikipedia have accepted LATEX formatas the default format for encoding mathematicsin their systems.

Hello, here issome text without a

meaning. This text shouldshow, how a printed text will

look like at this place. If you readthis text, you will get no information.Really? Is there no information? Isthere a difference between this text andsome nonsense like »Huardest gefburn«.Kjift – Never mind! A blind text likethis gives you information about theselected font, how the letters are writtenand the impression of the look. Thistext should contain all letters of thealphabet and it should be written in of

the original language. There is no needfor a special contents, but the lengthof words should match to the language. Hello,here is some text without a meaning. Thistext should show, how a printed text

will look like at this place. If you readthis text, you will get no information.

Really? Is there no information? Isthere a difference between this text andsome nonsense like »Huardest gefburn«.Kjift – Never mind! A blind text likethis gives you information about theselected font, how the letters are writtenand the impression of the look. Thistext should contain all letters of thealphabet and it should be written inof the original language. There isno need for a special contents,but the length of words

should match to thelanguage.

Text within a shape.

• More than 36 years have passed since the de-velopment of TEX system, but it is going strongwithout any challenge in the academic world,needless to say, it is highly preferred amongtechnical authors.

• The longevity of documents marked up in LATEXis remarkable. All documents that were writtenin the early days of TEX, i.e., three-four decadesago, still generate exactly the same output asthat produced thirty-forty years ago which issomething unheard of in modern day systemsthat are hardly backward compatible even acrossconsecutive versions.

• TEX provides guaranteed backward compatibil-ity. The TEXBook which is the manual written byDonald Knuth in early eighties, the sources ofwhich are publicly available, still generated thevery same book with modern day TEX systems.

Amino acid sequencing typeset with TEX.

Page 8: LaTeX—A Gentle Introductionbooks.sayahna.org/ml/pdf/stmse-ltx-intro.pdf · tent,beitbook,article,letter,reportandthelike. ThisiscalledL ATEX.TEXandLTEXareoftenused synonymously,butbeinformedthatthisdifferent

4 Semantic reasons

It separates the content and format unlike otherwysiwyg systems. For instance see the followingsource of a document:\head{Historical reasons}

\begin{itemize}

\item Developed by Donald Knuth, an academic.

\item Developed to typeset his own books,

notably, \emph{The Art of Computer

Programming}.

\end{itemize}

which would create an output as shown below:

Historical reasons

• Developed by Donald Knuth, an academic.

• Developed to typeset his own books, no-tably, The Art of Computer Programming.

It may be noted that formatting of text is done bysimple instructions like \emph, \item, \head, . . .,which unlike in the wysiwyg applications are notchosen from the menu, instead, it is written to thetext along with content. The formatting of thoseelements can uniformly be changed throughoutthe document if the definition for the instruction ischanged at one place which is the biggest advantageof keeping content and format separated.

The separation of format and content allows the au-thor to concentrate on the content without break-ing the train of thought and without losing himselfwithin the intricacies of the format of the contentwhich often happens with wysiwyg applications.

A homotopy diagram created with TEX.

Since the format is driven by separate style libraries,it is difficult to mess around the content and out-put.

LATEX allows for logical division of the content —books into parts, parts into chapters, chapters intosections, sections into subsections, so on and soforth. This helps to build up the content in the mostlogical and well structured order which provides ex-tra control.

Page 9: LaTeX—A Gentle Introductionbooks.sayahna.org/ml/pdf/stmse-ltx-intro.pdf · tent,beitbook,article,letter,reportandthelike. ThisiscalledL ATEX.TEXandLTEXareoftenused synonymously,butbeinformedthatthisdifferent

5 Technical reasons

Unlike word processors, the source file of a TEX doc-ument is simple text format making it more suscep-tible to any file corruption and is also light weightallowing easy transport across networks.

Various numbered objects in the document like sec-tion, figure, table, equation, theorem and the like arenot numbered in the document. A section will sim-ply be marked up as \section{...}, the number isserially computed and added to the heading by TEXduring output creation. This allows author the free-dom to move around the object in future if neededand also remove or insert an object at any locationwithout bothering the tedious task of re-numberingthe objects as in the conventional word-processingsetup.

M =

1 2 3 4 56 7 8 9 1011 12 13 14 1516 17 18 19 20

MT =

1 6 11 162 7 12 173 8 13 184 9 14 195 10 15 20

Transpose

NNT

Amatrix diagram.

LATEX has an excellent cross referencing system whichwill seldom let the user down. Each object that needsto be referred to is denoted by a key with the markup\label{<key>} which in turn will be recalled withthe help of another markup, \ref{<key>} which willfaithfully typeset the number of the object referredto. The user need not be worried in case any inter-vening objects are removed or inserted, the newlyrecomputed number will be correctly referred to.This saves a lot of time, drudgery and clumsinessand at the same time enhances the accuracy of thedocument remarkably with disproportionately lesseffort.

Usually, separate files are used for each chapter (oran appropriate logical chunk of text) in LATEX. Itmakes housekeeping simpler, interchange of chap-ters at a later stage if needed becomes painless, mean-ing, several nifty gritty points that would have both-ered otherwise are taken care of by TEX.

LATEX has the remarkable ability to typeset mathe-matics and adheres to the conventions of math ty-pography without any extra effort. See for example,

$a+b$ and $+a$

You will see that in the first case, + is consideredas an operator, leaving operator space around thesymbol while in the latter, + is considered as a signleaving no operator space between + and a.

a+ b and +a

Some of the math constructs cannot be done as eas-ily as in TEX in any other systems. For example:

TEX directly writes out PDF documents, thereby sav-ing investments on proprietary software to generatePDF. It can also dynamically create bookmarks, hy-perlinks, standards compliant PDFs, different kindsof PDFs from the same source as in the case of thisdocument which you are reading now.

LATEX can automatically generate table of contents,list of tables, figures and other objects, multiple in-dices, glossaries, sorted bibliographic listing, etc.,without any errors or omissions.

It further allows to translate the content to othermarkup formats like XML, HTML, Media-Wiki,Markdown and the like seamlessly.

Contrary to popular belief that TEX is useful to type-set only mathematics, it can very well be used totypeset varied contents like music scores and chessgames movements!

Music scores typeset with TEX.

TEX is now capable of accepting Unicode input andhence the best typesetting engine for Indic lan-guages, South Asian scripts and CJK family lan-guages. It can also typeset right to left scripts likeHebrew and Arabic. Text of any number of scriptscan be typeset in a single document.

Page 10: LaTeX—A Gentle Introductionbooks.sayahna.org/ml/pdf/stmse-ltx-intro.pdf · tent,beitbook,article,letter,reportandthelike. ThisiscalledL ATEX.TEXandLTEXareoftenused synonymously,butbeinformedthatthisdifferent

6 Where to get TEX?

TEX Users Group distributes TEXLive every year,which is the authorized version of the distributionfor thirteen operating systems. It is free for mem-bers of the Group, but is available for others for thecost of the media.

Online installation facility is available at https://tug.org/texlive.

Free package repository is available at: https://ctan.org and its thirty mirrors world-wide.

Free documentation of LATEX3 which is the newestincarnation of the macro library is available at: https;//latex-project.org.

The LATEX Tutorial of Indian TEX UsersGroup is available for free at: http://books.sayahna.org/en/pdf/primer.pdf. The PDF of theprimer is made available with thisdocument also.

Page 11: LaTeX—A Gentle Introductionbooks.sayahna.org/ml/pdf/stmse-ltx-intro.pdf · tent,beitbook,article,letter,reportandthelike. ThisiscalledL ATEX.TEXandLTEXareoftenused synonymously,butbeinformedthatthisdifferent

Radhakrishnan CV

Radhakrishnan is a free software ac-tivist and TEX programmer, one of thefounders of the Free Software Foun-dation of India and Indian TEX UsersGroup. He had organized two annual meetings ofthe TEX Users Group in Trivandrum in 2002 and2011. Wrote several packages (libraries) in LATEX andreleased under free license (lppl) at Comprehen-sive TEX Archive Network (ctan). He is one of thefounders of Sayahna Foundation.

He is married and lives with his wife in Trivan-drum.

Page 12: LaTeX—A Gentle Introductionbooks.sayahna.org/ml/pdf/stmse-ltx-intro.pdf · tent,beitbook,article,letter,reportandthelike. ThisiscalledL ATEX.TEXandLTEXareoftenused synonymously,butbeinformedthatthisdifferent

Epilog

◦ The content that Sayahna includes in these Phone PDFs arethose that can be read in under thirty to forty minutes. Com-puters or Desktop applications are not necessary for readingthem.

◦ The PDFs are made available in beautiful, rich formats andcan be easily read from your smart phones. They are cus-tomized to adhere perfectly with the dimensions of yourphone screen.

◦ Most smartphones these days are equipped with in-builtreaders for PDF content. However, the free Adobe AcrobatReader application offers the best reading experience. Wewould recommend that you install Adobe readers in yourphones and use them for reading our content.

◦ Anybody who is interested in open access publishing andwant to submit their work to Sayahnamay do so by mailingit to <[email protected]>. The work could be anything fromstories, memoirs, articles, interviews, movie reviews, po-ems, plays, sketches or paintings; the only stipulation beingthat they should be succint enough to be read under thirty tosixty minutes.

◦ Sayahna welcomes all your thoughts on our efforts! Youmayeither mail them to <[email protected]> or post them underthe Comments section in this web page. We eagerly awaityour feedbacks and hope to derive from them the necessaryimpetus to drive Sayahna to new heights.

Sayahna Foundation, jwra 34, Jagathy, Trivandrum 695014