Czech version
logolink

< Back to the list of lessons

Introduction to LaTeX system

ostatni-sinContent of the lesson:

  • Formation of TeX
  • Principle of System LaTeX
  • Usage of System LaTeX
  • Simple Example - Short Document

Formation of TeX

I will give two dollars and 56 cents to everyone who, as the first one, finds any mistake in my books. Donald Erwin Knuth

The Art of Computer Programming

The Art of Computer Programming (the shortcut is TAOCP) is a professional monograph written by Donald Knuth which consists of more parts. It contains the most important facts from informatics, descriptions of basic algorithms, their mathematic analysis etc. This publication is considered in general as the first publication for this subject; the American scientific magazine called American Scientist put it in the list of 100 most important "books about science" of 20th century (this list involves also popular publications, biographies, several novels etc.); TAOCP is also listed between 12 publications in the category "physical sciences" which classified Knuth between personalities like Paul Dirac or Albert Einstein (http://cs.wikipedia.org/wiki/The_Art_of_Computer_Programming). While working on these books Donald Knuth found out that the typographical quality of available resources for writing mathematical formulas was not enough. He created the computer typographical system TeX and used it to publish all his books.

The system TeX is used mostly at universities for publishing scientific articles. TeX is considered in general as the best tool for publishing complex mathematical formulas. However, it is also mostly used for common publishing as well as its derivatives like the set of macros called LaTeX. Also Wikipedia uses this system on its website to generate mathematical formulas. This system is commonly used for writing Bachelor's and Master's thesis at universities (https://akela.mendelu.cz/~rybicka/dahlia/zpract/dipp.pdf). Several universities do not accept any other system for writing any article or thesis.

A check which was given by D. E. Knuth to an unknown person who found a mistake in his book.

Knuthův šek

This image was downloaded from this page: http://en.wikipedia.org/wiki/File:Knuth-check2.png.

Principle of System LaTeX

The system TeX (the title TeX is derived from the beginning letters of word technology which means technology or art in Greek). It is determined to create electronic text documents and can offer quality algorithms for formatting paragraphs and pages of text. It was created in the end of 70s by Donald Erwin Knuth from Standford University in USA (http://www-cs-faculty.stanford.edu/~knuth). We can simply say that TeX is a compiler which gets a text file (containing commands for the composition), dimensions of characters and which generates a .dvi file from these details (the shortcut dvi means DeVice Independent - a file which is independent on device). This file contains placement of characters for every page. Then you have to decide which quality should be used and how you want to view the output. You can choose whether you want to view the result on a display, send it to a printer or use another device.

You can see the principle of TeX in the following image.

princip TeXu

What is common for TeX and LaTeX? The system LaTeX is a set of macros (a macro is a set of instructions which is launched by one command) which is used as an extension of the system TeX - these macros simplify creating documents for us. You can use macros for creating tables, structuring documents, creating content automatically etc. The problematic of LaTeX is explained in this book: LaTeX pro začátečníky (Rybička J., 2003) which describes working with this system for absolute beginners as well as for advanced users. Many publications about this system can be found in Internet too.

Advantages of LaTex:
  • the system offers perfect quality of output for mathematical texts,
  • documents written in this system are in plain text format (usually the extension .tex is used for text documents),
  • it is free of charge.

You can try the system LaTeX also via web interface TeX onWeb so you do not have to install anything on your computer. This system helps you to understand that not every text processor or text editor has to be WYSIWYG (acronym for "What You See Is What You Get". Label for an application which allows user to see the result of his document while creating it. When talking about this acronym, you should also know another one - WYSIWYM which means "What You See Is What You Mean" -- a typical example of this is XML markup language or LyX (a text processor for writing documents in LaTeX).) and also that free software can produce excellent quality of results.

An example of source code for the system LaTeX
\podkapitola{Úryvek druhý\,--\,Ekonomicko-matematická cvičení}
V~textu kapitoly 20 jsme tvrdili, že průměrné variabilní náklady se rovnají mezním nákladům pro první jednotku produkce. Tento vztah můžeme vyjádřit jako
$$\lim_{y\to 0}\frac{c_v(y)}{y}=\lim_{y\to0}c'(y).$$
Levá strana této rovnice není definována pro $y=0$. Její limita však definována je a~my ji můžeme vypočítat s~využitím l'Hôspitalova pravidla, které říká, že limita zlomku, jehož čitatel i~jmenovatel se blíží k~nule, je dána limitou derivace čitatele a~jmenovatele. Aplikací tohoto pravidla dostaneme
$$\lim_{y\to 0}\frac{c_v(y)}{y}=\frac{\displaystyle{\lim_{y\to 0}\mathrm{d}c_v(y)/\mathrm{d}y}}{\displaystyle{\lim_{y\to0}\mathrm{d}y/\mathrm{d}y}}=\frac{c'(0)}{1},$$
\noindent což potvrzuje naše tvrzení.

The following image is the final output of the previous source code (predefined styles were used):

ukázka výstupu LaTeXu

Usage of System LaTeX

You can use this distribution of LaTeX: http://cs.wikipedia.org/wiki/MiKTeX which can be used under Windows. The tutorial for installation can be found here: http://latex.feec.vutbr.cz/cz/latex/lokalni-instalace/instalace-miktex-2-7/.

Simple Example - Short Document

We can take a look on the result of LaTeX using a longer text written by Karel Čapek. The whole text was taken as a plain text (txt file) and was marked by commands for LaTeX. To simplify the sample, only two commands are used:

  • \chapter{} - a text is inserted inside the brackets. This command tells the compiler that the text inside brackets should be used as the chapter of this book,
  • \tableofcontents - this command creates content of the whole book. To be able to use this command, you have to compile the source code twice - the compiler collects information about chapters in the first pass and creates the content, chapters and page numbers in the second pass.

You can also see the header and footer inside the source code:

  • \documentclass{book} - this commands tells that the final document is a book (there are many commands in LaTeX which change the final appearance),
  • \usepackage{czech} - we set the language to Czech (LaTeX can handle many languages - also Japanese, Arabic etc.),
  • \begin{document} - this instruction indicates the beginning of our document and you can see its analogy in the end of file which ends the document.
Sample of short document in system LaTeX
\documentclass{book}
\usepackage{czech}
\begin{document}
\chapter{Karel Čapek -- ZAHRADNÍKŮV ROK}
Znění tohoto textu vychází z díla Zahradníkův rok tak, jak bylo vydáno v Československém spisovateli v roce 1983 (ČAPEK, Karel. Zahradníkův rok ; Měl jsem psa a kočku ; Kalendář. 14. vyd. Zahradníkova roku, 9. vyd. Měl jsem psa a kočku, 4. vyd. Kalendáře. Praha : Československý spisovatel, 1983. 392 s. Spisy, sv. 12.).
Další díla Karla Čapka naleznete online na www stránkách Městské knihovny v Praze: www.mlp.cz/karelcapek.
Elektronické publikování díla Karla Čapka je společným projektem Městské knihovny v Praze, Společnosti bratří Čapků, Památníku Karla Čapka a Českého národního korpusu.
\chapter{JAK SE ZAKLÁDAJÍ ZAHRÁDKY}
Zahrádky je možno zakládati několikerým způsobem; nejlepší je ten, že se na to vezme zahradník. Zahradník vám tam nasází všelijaké hůlky, proutí a košťátka, o kterých tvrdí, že jsou to javory, hlohy, bezy, vysokokmeny, polokmeny a jiné přírodní druhy; potom se ryje v hlíně, zobrací ji naruby a zase ji uplácá, udělá ze škvárů cestičky, nastrká tu a tam do země jakési zvadlé lupení, o němž prohlašuje, že to jsou pereny, naseje na příští trávník semínko, jež nazývá anglickým jílkem a psinečkem, psárkou, poháňkou a bojínkem, a potom odejde, nechávaje za sebou zahrádku hnědou a holou, jako byla dne prvého o stvoření světa; jen vám klade na srdce, abyste tu všechnu hlínu země denně pečlivě kropili, a až vzejde tráva, abyste si nechali přivézt na cestičky písek. Nu dobře.
.
.
.
A když jej zase potkáte, řeknu vám: "Musíte se přijít ke mně podívat; mně vám kvete jedna růže pernetka, to jste ještě neviděl. Tak přijdete? Ale jistě!"
Nu dobře: pojďme se k němu podívat, jak rok plyne.
\tableofcontents
\end{document}

The whole source code is available here: priklad-jednoducheho-dokumentu.tex and you can also see the pdf output here: priklad-jednoducheho-dokumentu.pdf.

Additional Texts

Links

Questions

  1. What do you understand under the term LaTeX?
  2. What do you know about the term WYSIWYG?
  3. Is there any system which can create documents and which is not WYSIWYG?
  4. How much does the system LaTeX cost?
  5. What do you know about the system LaTeX?
webdesign, xhtml, css, php - Mgr. Michal Mikláš