20 LaTeX – Document Preparation System – II

Mr. Hardik Joshi

epgp books
  1. LaTeX Document Structure

 

In the previous module we got familiarized with LaTeX typesetting system. We studied the LaTeX document structure which comprises of preamble and body sections. The preamble section is used to identify the type of document we want to create and the packages that are required to create documents. For example, suppose if we want to use Hindi fonts with LaTeX then we will use a package that supports Hindi fonts. Packages are available to provide enhancements to our LaTeX document.

 

Body of LaTeX Document

 

Now, let us focus on the body of LaTeX document structure. The body section is divided into three parts, top matter, main matter and the back matter. Let us explore each of these sections.

 

Top Matter

 

This section contains introduction to the document, details like title, author, creation date, abstract or executive summary, etc. The following is an example of top matter in LaTeX:

By default, LaTeX will use the word “Abstract” as a title for our abstract. If we want to change it into anything else, e.g. “Executive Summary”, we add the following line before we begin the abstract environment:

\renewcommand{\abstractname}{Executive Summary}

 

Main Matter of the LaTeX Document

 

The main content of document generally goes in the body section of LaTeX document structure. Usually the text that makes chapters or main content is written here. Following LaTeX commands are used in the body of any document:

Let us see a LaTeX code where both the preamble and body are used together. The LaTeX code and its output is shown in figure 1 where the document contains chapter, section and subsection. It must be noted that we are not supplying chapter number or section number. These numbers will be placed automatically by LaTeX depending on the settings (commands) given earlier.

 

Figure 2: Output of code shown in figure 1

Back matter of LaTeX Document

 

The back matter usually comprises of bibliography and index. If we have added citations in the main matter using commands like \cite, \cite[p.100], in that case, the bibliography can be automatically constructed during compilation using the following LaTeX commands:

Formatting fonts in LaTeX

 

LaTeX provides commands to format fonts. We can select font by specifying a package, apart from this, the style of font and its size can be specified using various commands. The list of commands and its effect is shown in following table:

The font size can also be modified using commands like \tiny… \Huge; a list of commands is given in extra reading notes.

 

Creating Wrapper Commands in LaTeX

We can create our own customized commands with the help \newcommand in LaTeX. Such commands are known as wrapper commands. Wrapper commands are used to ease our task of typing difficult commands or longer commands. It is like aliasing a command so that we can use it easily. In LaTeX, \newcommand can define a logical wrapper command. An example of using wrapper command and its output is shown below:

 

Using Environment in LaTeX

 

Environments are used to format blocks of text in a LATEX documents. When we wish to apply common settings to multiple statements, environment can be used. The environment keyword is used to define a block as shown below:

 

Listing in LaTeX

 

LaTeX provides commands to create lists. List structures in LaTeX are simply environments which essentially come in three types:

  • itemize for a bullet list
  • enumerate for an enumerated list and
  • description for a descriptive list

The syntax to create list with an example is given in the following code. In the below example, we are creating list that has bullets and numbering. We used the keyword enumerate to create a numbered list within which we have created a bulleted list using itemize keyword.

We use “\\” to indicate new line in LaTeX code. In the previous example, we had used the package “setspace” to modify the spacing between lines. Spacing can be applied by mentioning keywords like singlespace, doublespace, etc. or by specifying the space distance in numbers like “3.5” and so on.

 

Tables in LaTeX

 

Tables can be inserted using the “tabular” keyword. Number of columns can be indicated by “c” arguments to the tabular command. The following code demonstrates the use of tabular command along with its output on right hand side.

Mathematics in LaTeX

 

We can represent mathematical equations and expressions using the inline style or using the command within an environment. The inline style is used to write expressions within the paragraph, while commands can be used to write separate equations. Following code shows how inline style can be used within our sentences.

Another way of writing mathematical expressions is called “displayed style”. Let us see the syntax of displayed style:

The following code and its output show how the styles can be used along with its output shown on the right hand side:

There are commands to denote subscript ( _ ), superscript ( ^ ) which are used in the following expressions:

 

Few other features of LaTeX

 

Graphics

 

LaTeX supports the use of graphics, plots, etc. We can include images that can be of vector or raster formats. The graphicx package has several commands to place image at desired position. We can also use commands to provide caption to images and describe the image for indexing purpose. Few examples of using graphicx package is given in extra reading notes. With the help of packages 2D and 3D plots can also be created. Packages for creating 2D and 3D vector graphics are:

  • TikZ
  • PSTricks
  • MetaPost
  • Asymptote (3D)

 

Classes & Styles

 

Most of the conferences, publishers accept scholarly articles in a specific format. LaTeX provides functionalities like classes and styles using which we can create templates. These templates help the authors to avoid the hassle of using formatting commands, rather it makes simpler to use templates that will format the document in desired way. Generally, the templates are used to identify the margins, headers, footers, font formatting and paragraph & line spacing. Class files (.cls) and styles (.sty) are supplementary files that increase the functionality of LaTeX. They contains \documentclass{…} and \usepackage{…} commands. The class file will determines the overall structure of the document. Packages, or style files, are then used to provide anything else that the class doesn’t accommodate

Let us summzarize what we have learnt in this module:

  • LaTeX has variety of formatting options for fonts, paragraphs, text, lists, tables etc.
  • LaTeX is rich in symbols for Mathematical expressions
  • Mathematical expressions can be embedded inline or using environment
  • LaTeX uses variety of classes & packages to create presentations and graphics
  • Classes & Styles can be used with LaTeX to improve the functionality
you can view video on LaTeX – Document Preparation System – II

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, Birkhäuser.
  14. Alan. Hoenig. 1998. TeX unbound : LaTeX & TeX strategies for fonts, graphics, & more, Oxford University Press.
  15. George A. Gratzer. 1999. First steps in LaTeX, Birkhäuser.
  16. 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.
  17. George A. Gratzer. More math into LaTeX,
  18. D.F. (David Francis) Griffiths and Desmond J. Higham. Learning LaTeX,