Macros – How to Maintain and Organize Macros File in LaTeX

macros

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?

Regards.

Best Answer

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

\NeedsTeXFormat{LaTeX2e}     % Not really necessary
\ProvidesPackage{sauravmacros}

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

\newcommand{\foo}{foo}
\newcommand{\bar}{bar}

\newenvironment{mytheory}[1]{%
}{}

\endinput

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!

Related Question