#### Using formats

When TeX typesets a document, it must process the document header, which may contain a large number of \input, \include, and \usepackage statements. Every time the document is typeset, this process is repeated even though large portions of the header did not change.

TeX has a built-in mechanism to speed up this process. It can be instructed to process lines of source and output the result to a "format file." When TeX typesets after that, it can rapidly read the format and then typeset the document. LaTeX is constructed in this manner; the format file is created when TeX is installed on your machine and the command "latex file" tells TeX to read this format and then typeset "file".

When machines were slower, users often created their own format files to speed up typesetting. This is done less often today, but dealing with format files may still be useful. For instance, some organizations create and distribute a format to be used by everyone working on a common project. In this section we'll explain how to use a format file provided by someone else, and how to create a format.

A typical format file has extension "fmt". Suppose a department of the University of Oregon has provided a format "uo.fmt". To use this format, follow the steps below:

- Move uo.fmt to "~/Library/texmf/web2c/uo.fmt". You may need to create some of these directories.
- Create a new "engine file" by going to ~/Library/TeXShop/Engines and duplicating the file XeLaTeX.engine. Engine files need to have the execute bit set, and this duplication step automatically does that.
- Rename this new file. The name need not match the name of the format. Since the name will appear in the TeXShop interface, it should make sense to a user. We'll choose "Oregon.engine".
- Open Oregon.engine in TeXShop and edit it to read as follows
    #!/bin/tcsh
    set path= ($path /usr/texbin /usr/local/bin)
    pdflatex -fmt uo "$1"
  The first two lines will already be present, so it may only be necessary to change the third line. However if your machine has an Intel processor, the word "powerpc" in the second line should be changed to "i386".

This completes the installation. The next time you start TeXShop, the pulldown menu beside the typeset button on the Source Window Toolbar will list "Oregon" as an option. Choose this to typeset using the uo.fmt format. If you want this typesetting method to be the default, go to TeXShop preferences under the Typesetting tab, and in the Default Command box select "Command Listed Below" and fill in the edit box with the word Oregon.

It is also possible to select the Oregon format for a particular document without changing the typesetting option. To do that, add the following line to the top of the source file:

  %!TEX TS-program = Oregon

Then uo.fmt will be used for that document regardless of the typesetting option chosen.

The above instructions assume you have a format for pdflatex. You can also make formats for plain tex; in that case change "pdflatex" to "pdftex" in the engine file.

It is also possible to use formats when you are typesetting with tex + ghostscript. TeXShop assumes that an engine file contains one or more command line instructions and ultimately produces a pdf file. So the engine file must contain the commands which convert the dvi file to a pdf file. Here is a typical engine file for uo.fmt in that case:

  #!/bin/tcsh
  set path= ($path /usr/texbin /usr/local/bin)
  latex -fmt uolatex "$1"
  set filename = "$1"
  dvips "${filename:r}.dvi"
  pstopdf "${filename:r}.ps"

#### Making formats

Format files contain the internal binary representation of typeset lines of source. This representation depends on the processor and particular TeX implementation. Thus it is rarely possible to use a format file from someone else unless that person has the same machine and TeX installation that you do.

However, it is common for organizations to distribute the source lines needed to construct a format. In that case you'll be told to make the format using "initTeX". For example, suppose this source text is "uo.tex". To make the format, open Apple's Terminal program and change to the directory containing the source for the format. Then type

  pdflatex -ini

You will get a ** prompt. Type the following line at the prompt

  &pdflatex uo

and press return. The format file will be created. At the end you may have to issue a "\dump" command if the format source doesn't contain it. This will produce the required "uo.fmt".

You might like to try this with the follow "uo.tex" file:

  \documentclass[11pt]{article}
  \usepackage{geometry}
  \geometry{letterpaper}
  \usepackage[parfill]{parskip}
  \usepackage{graphicx}
  \usepackage{amssymb}
  \usepackage{epstopdf}
  \DeclareGraphicsRule{.tif}{png}{.png}{`convert #1 `dirname #1`/`basename #1 .tif`.png}
  \dump

Advanced Help
TeX Formats