[Tex/LaTex] Is it possible to create a LaTeX preamble “header”

external filesinputpreamble

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!

Best Answer

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.

Related Question