Possible Duplicate:
How to make a standard preamble into a package

I often have the same preamble stuff in my documents that kind of clutter the work space a bit. Some are custom commands I've stolen from here or there and some are calls to packages.

In R I can use a function called source that allows me to create an external file of these commands and then I can just call source to read this external file and it's magically in the working memory (LINK to source info). It would be nice to do the same with LaTeX. Does LaTeX have this kind of capability?


1 Answer 1


There are three ways to outsource your preamble:

  1. (The easiest one) Separate .tex file, say preamble.tex. Usage:

    \input{preamble} % NOT \include and NO file ending!

    where preamble.tex consists of the usual:

    % own settings, stuff, etc.
  2. Custom class (.cls) or package (.sty) file. Usage:

    \usepackage{other packages, only for this document}

    Your custom package can be simply just the same as the aforementioned preamble.tex (but with .sty), but you can also write a package that is quite dynamic, see for example: Reference guide to begin writing a class and/or a package

  3. Pre-compiled preamble

Not the answer you're looking for? Browse other questions tagged .