[Tex/LaTex] Where to put a custom macros file

automationincludemacrospreambletexmf

I have a bunch of common commands I put in document preambles. I don't always use them all, but it makes the preamble too long for my tastes.

I want to put them all in an external file (preferably in my user texmf tree). A class file seems like overkill; it isn't robust and I don't know TeX anyway. Creating a package seems intimidating as well. Can I just put the macros in a macro.tex in my tree and use \include{macro.tex} in my preamble? Also, could I include the same after \begin{document}?

Best Answer

Just put them all in a mymacros.sty file and add the single line on top (which is also optional!):

\ProvidesPackage{mymacros}[2011/02/23 v1.0 My own macros]

That's all what is required for a simple package. No plainTeX knowledge required. Load it as usually using \usepackage{mymacros}

Please note that \include can't be used in the preamble. For this kind of files (as .tex without the above code line) you need to use \input.

Related Question