TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When downloading a new package and running

tex packagename.ins

you always get a bunch of files, including the .def file. It's also mentioned in the .sty file. Apparently it's a definition being used for something.

What exactly is it for though? And can it be omitted when sharing the LaTeX project?

share|improve this question
It depends on the package concerned. Usually, any .def will be needed, and so you should install them. – Joseph Wright May 13 '12 at 14:01
up vote 14 down vote accepted

Usually files with the extension .def collect long lists of similar definitions, that would make a .sty file long and unreadable, or that can possibly be shared with other packages.

If tex packagename.ins creates a .def file, then this is part of the package structure and mustn't be omitted.

A typical example are the <encoding>enc.def files, such as t1enc.def loaded by fontenc:

 [2005/09/27 v1.99g
         Standard LaTeX file]

where having the long list in a separate file makes it more easily maintainable and searchable. Similarly inputenc uses .def files for lists of pairings between input characters and their connected output.

Some other packages use some .def files for "context dependent" code. Examples are graphics/graphicx and hyperref that put the engine dependent code (for latex/dvilualatex, pdflatex/lualatex and xelatex) in .def files such as pdftex.def and dvips.def (graphics) or hpdftex.def and hdvips.def (hyperref).

Other packages, notably bidi, xepersian or minitoc, use .def files to load code depending on what packages are loaded in the document.

In some cases perhaps an extension such as .sto ("style option", modelled after .clo used by the standard classes) might have been preferable, but tradition has its influence. So long as the names are unique, the extension used is irrelevant.

share|improve this answer
Also compiler dependent things are put into .def files and the correct one is then loaded (e.g. pdftex.def if pdflatex is used) – Martin Scharrer May 13 '12 at 14:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.