19 LaTeX – Document Preparation System – I

Mr. Hardik Joshi

epgp books

 

1.    Overview and History of LaTeX

 

Tex and LaTeX are document preparation systems. Applications like Microsoft Word, LibreOffice Writer, Apple Pages etc. are word processors that are classified as “what you see is what you get” (WYSIWYG) processors. While using word processors, our focus is more on formatting rather than typing the content. However, LaTeX helps in focusing on content without bothering about formatting as seen in the output of the documents. LaTeX is a typesetting program, where we use various commands along-with the document. LaTeX has its own markup language, so once the program is written, we compile it to produce a formatted document. These documents can be in “.pdf” or “.ps” format that are printer ready documents.

 

Tex is a computer program created by Donald Knuth for typesetting of documents. It is used for document preparation that helps in converting a file in the appropriate form to be printed on variety of printers and high-resolution typesetting systems. Tex was basically developed to write mathematical expressions and prepare documents that involved mathematics.

 

LaTeX is a set of macros that were developed for Tex. LaTeX was developed by Leslie Lamport and was initially released in 1985. LaTeX is the shortening of Lamport Tex. These macros reduce the user‟s task so that users can easily focus on writing the content. LaTeX takes care of all formatting processes. LaTeX is released under the LaTeX public project licenses (LPLL).

 

LaTeX is essentially a markup language. The text documents of LaTeX source consists of plain text, with certain portions of the text are marked up using different markers known as commands. These command can be classified as independent commands or non-independent commands, independent commands do not mark any specific part of the text. These commands can perform a variety of tasks when the document is processed by the LaTeX system. The commands may provide information about the text or the document, they may specify formatting, or they may instruct LaTeX to process the document in a certain way (for example, use a certain page size, start a new chapter only on an odd-numbered page etc.).

Figure 1: Tex file created using LaTeX commands

Figure 2: Output of tex file (source: https://en.wikipedia.org/wiki/File:LaTeX_example.svg)

 

Figure 1 illustrates a tex file (LaTeX source document) that is typed in markup language, the output of the tex document is illustrated in figure 2. Output can be a dvi file, ps file or pdf document.

 

LaTeX can be used to create documents like articles, books, letters, resumes etc. An author uses markup tags to define the general structure of LaTeX document and to stylize the text throughout the document. LaTeX also provides features to add citations, cross-references, create slide shows etc. Modern LaTeX implementations support multiple languages including south-Asian languages. Few features of LaTeX are as follows:

  • LaTeX is a superior typesetting quality (especially mathematical expressions)
  • LaTeX is a free software and distributed under the LPPL License
  • It is idely used by Scientific and Academic community
  • It supports variety of text editors & systems
  • LaTeX is flexible and supports lot of packages
  • LaTeX allows the user to focus on content rather than formatting
  • no need to remember margins, spacing, font size, etc.
  • no need to manually number sections, tables, figures, footnotes, citations, references, etc.
  • automatic creation of table of contents, index, etc.
  1. LaTeX Workflow

LaTeX documents are scripts that can be compiled to generate the output file. LaTeX is a markup language so the source documents are typed in markup language. These documents are saved as tex file. We can apply tools to generate dvi file, ps file or pdf file on processing the tex file. Various commands that can be used for document processing is shown in figure 3.

Figure 3: Compilation of tex documents

  1. Installation of LaTeX

LaTeX supports many different operating systems. In this section, we will see how to install LaTeX for MS Windows and Linux OS. There are various tools/editors available to type the source files for LaTeX documents and various software to compile and generate the output files in dvi, pdf or ps format.

 

Installation in Windows

 

We must follow the following steps to setup LaTeX environment for Windows:

  • Install MiKTeX (A distribution of typesetting program for Windows)
  • Install GhostScript or GSView (Viewers for ps file)
  • Install PDF readers like Adobe Acrobat or Foxit Reader
  • Install Editors like Kile / TeXnic Center / Scite / LaTeX Plugin for Eclipse etc.

Figure 4: Kile editor for typesetting in LaTeX

 

Installation in Linux

  • TexLive is a major TeX distribution for Linux
  • Kile is a TeX/LaTeX editor developed by KDE as is user friendly
  • Kile is available for operating systems such as Linux and Microsoft Windows.
  • Above mentioned editors can be installed using synaptic package manager or by using yum, apt-get command

LaTeX is also available as portable distribution; the user need not install LaTeX in their system. Another solution is to use online services for LaTeX. There are many websites that provide online editor for typing LaTeX programs and compilers to process the documents.

  1. LaTeX Commands and Arguments

LaTeX commands always start with a \ (backslash) character and is followed by the command name. The command name may be a single non-letter character or a string of alphabetic text. All LaTeX commands are case-sensitive. Some commands may accept additional information (for example, the \textcolor command expects the color in which the text is to be displayed). This additional information is called arguments.

 

There are two types of arguments in LaTeX. Optional arguments are not mandatory. We may or may not provide them. If we want to provide one or more optional arguments, we write them after the command name, enclosed in [] (square brackets) and separated by comma. These commands are followed by mandatory arguments (if there are any) in {} (curly braces) with each mandatory argument written in its own set of curly braces. For instance, if we use a command \documentclass{10pt]{article}; then the “documentclass” is the name of the command, 10pt is an optional argument while article is a compulsory argument.

 

LaTeX environment treats all white space characters like newline characters, tab and space characters as the same. LaTeX converts all occurrences of multiple consecutive whitespace into a single space character. The white spaces at the beginning of a line are generally ignored and one or more consecutive blank lines are considered to mark the beginning of a new paragraph. This means that even if we type your text as several lines, it will appear in the output as a continuous flow unless there is a blank line it. To insert a break in line, we use \\ (the line break command) at the end of each line except the last line in the paragraph.

 

The following characters are reserved in LaTeX:

 

„$‟, „#‟, „%‟, „&‟, „_‟(uncerscore), „{„, „}‟, „^‟, „~‟, „\‟

 

These characters have a special meaning in LaTeX. These characters cannot be used directly in our text document in LaTeX. If we want to use them in our text, we must us the escape sequences as shown below:

 

„\$‟, „\#‟, „\%‟, „\&‟, „\_‟(uncerscore), „\{„, „\}‟, „\^‟, „\~‟, „\textbackslash{}‟

 

  1. LaTeX document Structure

All LaTeX documents adhere to a document structure. The LaTeX documents must be typed using the standard document structure. All LaTeX documents are classified into two parts, preamble and body. The body part of LaTeX document can be further classified as front matter, main matter and back matter.

 

 

The preamble consists of commands \documentclass{} and \usepackage{}. The top matter consists of general information about the document and its author. Commands like \title{}, \author{}, \address{}, etc. form the top matter of the LaTeX document body structure. The actual content that is made up of sections and sub-sections go in the main matter while the bibliography portion forms the back matter of any LaTeX document.

Figure 5: LaTeX document structure

 

Figure 5 illustrates various commands corresponding to the LaTeX document structure. Let us explore the preamble portion of the document structure.

  1. Preamble Portion

The preamble portion of LaTex document structure contains the \documentclass to identify the type of document (article, book, reports, slides, etc.) and the \usepackage command to identify the extra packages that will be used with the latex document.

 

\documentclass command

 

When processing an input file, LaTeX needs to know the type of document the author wants to create. This is specified with the \documentclass command. The options available with \documentclass are listed in following table:

\usepackage command

 

If we want to include graphics, colored text or source code from a file into our document, we need to enhance the capabilities of LaTeX. Such enhancements are called packages. Some packages come with the LaTeX base distribution. Others are provided separately. Modern TeX distributions come with a large number of packages pre-installed. Following is the usage of \usepackage command:

In the above example, we are using packages to create index {makeidx} and packages that support other languages {inputenc} package. In the next module, we will see few more commands that can be helpful to type the documents; the commands related to the body of document structure of LaTeX documents.

 

Let us summarize the contents discusses in this moduel

  • LaTeX is used for typesetting of documents
  • LaTeX is WYMIWYS
  • LaTeX has various editors that install on different OS
  • Few basic commands of LaTeX
  • Document structure of LaTeX
you can view video on LaTeX – Document Preparation System – I

References

  1. Leslie Lamport. 2006. A Document Preparation System LATEX 2nd ed., Pearson Education.
  2. Jon. Emmons and Terry Clark. 2006. Easy Linux commands : working examples of Linux command syntax, Rampant TechPress.
  3. Richard Blum. 2008. Linux command line and shell scripting bible, Wiley Pub.
  4. William E. Shotts. 2012. The Linux command line : a complete introduction, No Starch Press.
  5. Daniel J. Barrett. 2016. Linux pocket guide : essential commands, O’Reilly Media.
  6. Mark G. Sobell and Matthew Helmke. A practical guide to Linux commands, editors, and shell programming,
  7. Wikibooks contributors. 2005. LaTeX, Platypus Global Media.
  8. Bernice Sacks. Lipkin. 1999. LaTeX for Linux : a Vade Mecum, Springer New York.
  9. Michel. Goossens and S.P.Q. Rahtz. 1999. The LaTex Web companion : integrating TeX, HTML, and XML, Addison Wesley Longman.
  10. Michel. Goossens, S.P.Q. Rahtz, and Frank. Mittelbach. 1997. The LaTex graphics companion : illustrating documents with TeX and PostScript, Addison-Wesley.
  11. Apostolos. Syropoulos, Antonis. Tsolomitis, and Nick. Sofroniou. 2003. Digital typography using LaTeX, Springer.
  12. Marc R.C. van. Dongen. 2012. LaTeX and friends, Springer.
  13. George A. Gratzer. 1999. First steps in LaTeX, i e .
  14. Alan. Hoenig. 1998. TeX unbound : LaTeX & TeX strategies for fonts, graphics, & more, Oxford University Press.George A. Gratzer. 1999. First steps in LaTeX, i e .
  15. V. Ramakrishnan, National Research Council (U.S.). Transportation Research Board., American Association of State Highway and Transportation Officials., and United States. Federal Highway Administration. 1992. Latex-modified concretes and mortars, Transportation Research Board, National Research Council.
  16. George A. Gratzer. More math into LaTeX,
  17. D.F. (David Francis) Griffiths and Desmond J. Higham. Learning LaTeX,