Is it possible to create a header in LaTeX containing my usual preamble, functioning similar to a header in C? Specifically, can I write a text document (or something similar) with the preamble that I usually use, and type something in my documents' preambles that effectively pastes this document there? In particular, so that I can change this document, and have all of my TeX documents' preambles effectively updated? (I keep making small changes in one document, and updating all the others is getting rather troublesome...) Thanks!


2 Answers 2


If I understand your question correct, you want a file containing your preamble and you want to include it in every document. Then just put the parts of the preamble that are not document specific into a file and save that file somewhere in the LaTeX search path, e. g. $SOMETEXMFDIR/tex/latex/mypreamble/mypreamble.tex. You can get a list of valid values for $SOMETEXMFDIR by executing kpsewhich --expand-path='$TEXMFLOCAL' (at least in TeX Live) if all users have to access the file. If you want to use it from your account only than kpsewhich --expand-path='$TEXMFHOME' is the better choice.

You can then \input{mypreamble.tex} in every document, see the answer from Stephan Lehmke.

For a more advanced technique see also the question How to make a standard preamble into a package.

  • This is indeed exactly what I am asking, though I'm having trouble seeing where exactly to put the preamble file. I'm not sure how to use that command you gave. Thank you for the answer.
    – Curtis
    Aug 26, 2012 at 8:01
  • @Curtis: The kpsewhich tool is a command line tool to search for TeX related stuff on your machine. It works in TeX Live, I think Miktex has a similar tool. The syntax may vary between different operating systems and TeX distributions, especially the escaping of the $. Google knows the valid commands and syntax for your OS and TeX distribution, but the principle holds.
    – Chris
    Aug 26, 2012 at 8:07

That's a pretty basic mechanism in (La)TeX which you can also use to "separate out" other parts of your document.

Simply paste any number of lines into a new text file (say, file.tex) and then input it by putting


in the place where the lines used to be (note you can leave out the .tex extension).

\input will act exactly like 'pasting' the file contents at the place it appears on.


You must log in to answer this question.

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