I maintain a macros file which is static over all my documents. Whenever I need to make a new document, I copy the macros file in the folder and start working on it. Now the problem is I have several copies of the macros file all over my computer. If at a later stage I change a command or add new command to the macros file, I will have to replace all the macros file in order to maintain uniformity. I have now completely lost track of versions of the macros file.

  1. What is the standard way of maintaining the macros file?
  2. Is it preferred to keep it on the cloud and may be use GIT to pull every time?
  3. Often labs have a common macros file as well. How should it be maintained?


  • Make a self-defined package name mymacros.sty, copy your definitions to it and place it in your local texmf directory such that TeX can find it. That's what packages are designed for! Similar, but not really a duplicate: tex.stackexchange.com/questions/273862/… – user31729 Nov 24 '15 at 9:57
  • That seems like a solution. However, I found this tex.stackexchange.com/questions/11890/… and I suppose it says exactly the same thing. I will delete my question in some time. – Marvin Nov 24 '15 at 10:05
  • I do hope to receive answers to point 2 and 3 as well. – Marvin Nov 24 '15 at 10:08
  • 2
    A good advise will also be to document every of these macros. If you got them from this site, perhaps include the share link in a comment. This way seldom used macros will be explained, and you will know why you added them even if you forgot about them several months after you added them – daleif Nov 24 '15 at 11:10
  • 2
    If you use Git, you can include the macros repo as a submodule. That way it is always clear, which document uses which version of the macros - even if you (by accident or on purpose) break backwards-compatibility or make design changes. This also works quite nice in teams. You can even make different branches etc. – hbaderts Nov 24 '15 at 11:57

Make a sauravmacros.sty file with this content and place your macros and other definitions there.

\NeedsTeXFormat{LaTeX2e}     % Not really necessary

%\RequirePackage{...} %which ever package(s) you need




With more and more macros etc. you will change this only and provide options, perhaps.

Place it in the local directory or in your local texmf path, which depends on the OS. See the environment variable $TEXINPUTS on Linux for example.

As for the cloud - storage: That's a personal opinion and matter of taste, I consider to do this so in future too, but not in a public repository.

The common macro file of labs etc. should not be treated differently. If all is on a server accessible for all users the common lab macro file is basically treated the same as a local personal file -- the question is rather who has the administrative rights to change this. I really suggest to use a versioning system then!

| improve this answer | |

Create you own package, and put them in your texmf tree. A package is just a macro file with these characteristic:

  • .sty extension
  • no need of \makeatletter\makeatother
  • a \ProvidesPackages command.
  • using \RequirePackage instead of \usepackage.

You should indeed versionning it, for example with git.

Cf my own macro file https://git.framasoft.org/maieul/philologue/blob/master/philologue.sty

| improve this answer | |

For my setup, putting the macros in the TeX tree is not a good option because I synchronize my user directory among different machines.

What I do with macros and bibliography is to put them at the top of my working tree. Then in a new document I use something like \input ../../macros.tex .

| improve this answer | |

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.