Processing TeX and LaTeX Files
Living Linux

Processing TeX and LaTeX Files

04/12/2000

As I mentioned a few weeks ago, one of the more popular and capable typesetting tools for Linux is TeX. It comes with all of the major Linux distributions. The TeX system itself, a large collection of files and data, is packaged in distributions; TeTeX is the TeX distribution designed for Linux, and you can find it on the Web at http://www.tug.org/teTeX/.

Donald Knuth, the world's foremost authority on algorithms, wrote TeX in 1984 as a way to typeset his books, because he wasn't satisfied with the quality of available systems. Since then, many extensions to the TeX formatting language have been made -- the most notable being Leslie Lamport's LaTeX, which is designed to facilitate the typesetting of structured documents. (LaTeX probably gets more day-to-day use than the plain TeX format, but in my experience, both systems are useful for different kinds of documents.)

While not everyone wants needs to write documents with TeX or LaTeX, these formats are widely used, especially on Linux systems. So every Linux user has the potential to encounter one of these files. This column tells you how to deal with them.

Getting sample input

When someone writes a document with TeX, they compose an input file, which is a plain text file that contains the text of the document, with the TeX formatting commands interspersed in it.

So first, we'll need to get some sample input files to process.

For the following examples, we'll use some tutorial files written on the subject of learning TeX and LaTeX itself -- Michael Doob's A Gentle Introduction to TeX and Tobias Oetiker's The Not So Short Introduction to LaTeX. These tutorials are available on the Net in the respective formats they describe. You can download them here:

  • A Gentle Introduction to TeX (TeX format)
  • The Not So Short Introduction to LaTeX (.zip)

The TeX input for A Gentle Introduction to TeX is one file, called gentle.tex.

The Not So Short Introduction to LaTeX is a somewhat larger document, and its chapters have been put in separate files. So the LaTeX input is a collection of several files in a .zip archive -- after you download it, use the unzip tool to extract all of the files:

$ unzip src.zip

This command makes a new subdirectory, called src, which contains all of the LaTeX input for this document.

To view or print a TeX or LaTeX document, you process its input file.

Is it a TeX or LaTeX file?

TeX and LaTeX files are processed with different commands. So, the first step is figuring out which format a file is in.

By convention, TeX files always have a .tex file name extension.

LaTeX input files sometimes have a .latex or .ltx file name extension instead -- but not always. One way to tell if a .tex file is actually in the LaTeX format is to use grep to search the file for the text "\document", which every LaTeX (and not TeX) document will have. (The regular expresion to use with grep is '\\document', since slash characters must be specified with two slashes.)

For example, to determine whether the file "gentle.tex" is a plain TeX or LaTeX document, type:

$ grep '\\document' gentle.tex RET

$

In this example, grep returned to the shell prompt without matching and printing any lines at all, so you can safely assume that the file gentle.tex is a plain TeX document.

[1] [2] Next

Close    To Top
  • Prev Article-OS:
  • Next Article-OS:
  • Now: Tutorial for Web and Software Design > OS > Linux > OS Content
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Geek Tutorial
     

    Blogging Tutorial

      RSS Tutorial
      Podcasting Tutorial
    Graphic Design Tutorial
      Coreldraw Tutorial
      Illustrator Tutorial
      3D Tutorials
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial/ Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial/ Articles
     

    XML Style

      AJAX Tutorial
      XML Mobile
    Flash Tutorial/ Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial/ Articles
      Linux Tutorial
      Symbian Tutorial
      MacOS Tutorial
    Personal Tech
      Hardware Tutorial
      Software Tutorial
      Online Auction