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?


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.

  • 2
    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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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