LinuxDevCenter.com

oreilly.comSafari Books Online.Conferences.

We've expanded our Linux news coverage and improved our search! Search for all things Linux across O'Reilly!

Search
Search Tips

advertisement

Listen Print Subscribe to Linux Subscribe to Newsletters
Linux & Unix > Excerpts >
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.

Pages: 1, 2

Next Pagearrow




Tagged Articles

Be the first to post this article to del.icio.us

Recommended for You

  1. Cover of SpamAssassin
    SpamAssassin
    Print: $29.99
    Ebook: $23.99
  2. Cover of Backup & Recovery
    Backup & Recovery
    Print: $49.99
    Ebook: $39.99
  3. Cover of Linux in a Nutshell
    Linux in a Nutshell
    Print: $44.95
    Ebook: $35.99
  4. Cover of Motif Reference Manual, VOL.6B
    Motif Reference Manual, VOL.6B
    Print: $49.95

Sponsored Resources

  • Inside Lightroom
Advertisement

Sponsored by:

O'Reilly Media

©2010, O'Reilly Media, Inc.
(707) 827-7000 / (800) 998-9938
All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.
About O'Reilly
Academic Solutions
Authors
Contacts
Customer Service
Jobs
Newsletters
O'Reilly Labs
Press Room
Privacy Policy
RSS Feeds
Terms of Service
User Groups
Writing for O'Reilly
Content Archive
Business Technology
Computer Technology
Google
Microsoft
Mobile
Network
Operating System
Digital Photography
Programming
Software
Web
Web Design
More O'Reilly Sites
O'Reilly Radar
Ignite
Tools of Change for Publishing
Digital Media
Inside iPhone
makezine.com
craftzine.com
hackszine.com
perl.com
xml.com

Partner Sites
InsideRIA
java.net
O'Reilly Insights on Forbes.com