Linux DevCenter    
 Published on Linux DevCenter (http://www.linuxdevcenter.com/)
 See this if you're having trouble printing code examples


Living Linux

Document Templates for TeX and LaTeX

04/21/2000

Last week I showed how to process TeX and LaTeX input files. Now that you're familiar with how to print and preview these files, we can start making input files using these simple, boilerplate templates.

To make a document with TeX or LaTeX, you generally use your favorite text editor to write an input file containing the text with the appropriate markup. Then, you process this TeX or LaTeX input file to create an output file in the DVI format, which you can then preview, convert or print.

What an input file looks like

For presenting a programming language, it's an old tradition among programmers to give a simple program that just outputs the text "Hello, world" to the screen; such a program is usually just detailed enough to give those unfamiliar with the language a feel for its basic syntax.

We can do the same with document processing languages like TeX and LaTeX. Here's the "Hello, world" for a TeX document:

Hello, world
\end

If you processed this file with tex, it would output a DVI file that displayed the text "Hello, world" in the default font on the default page, with default margins. Here's the LaTeX equivalent:

\documentclass{article}
\begin{document}
Hello, world.
\end{document}

Even though the TeX example is simpler, LaTeX is generally easier to use for making structured documents, while TeX is better for more experimental layouts or specialized documents.

Using the templates

To write a document with a template, insert the contents of the template file into a new file that has a .tex or .ltx extension, and edit that. (Use your favorite text editor.)

To make sure that you don't accidentally overwrite the actual template files, you can make them read only, like this:

$ chmod a-w template-file-names RET

The bracketed, uppercase text in the templates explains what belongs there; fill in these lines with your own text, and delete the ones you don't need.

Then, process your file with either the latex or tex command as discussed last week, and you've got a typeset document!

Continue to the next page for the templates.

Note:You can download the templates below individually with the links provided, or view a listing of all of them here.

LaTeX templates

Use the latex command to process these templates.

TeX templates

Use the tex command to process the these templates.

More templates

Here are some more complex template packages on the net that you might want to look at:

Next week: printing banners and signs.

Michael Stutz was one of the first reporters to cover Linux and the free software movement in the mainstream press.

Read more Living Linux columns.

Copyright © 2009 O'Reilly Media, Inc.