# How to reuse new command among different files to keep them consistent?

I have several .tex files with \newcommand in the beginning, I found it really cumbersome to copy and paste these new commands each time I have a new .tex file, and it is easy to make mistakes and hard to keep the new commands up to date. Is there a way to make a head file with all my new commands, typeset it so that the new commands apply to all my tex files?

• Create your own \mycommands.sty style file, so that each invocation of it is merely \usepackage{mycommands}. It starts with \ProvidesPackage{mycommands} and ends with \endinput. What goes in between is up to you. Jan 13 '17 at 16:58
• write all the defines in a separate file and use \include or \import tex.stackexchange.com/questions/246/… Jan 13 '17 at 16:58
• Note that Steven meant to write mycommands.sty not \mycommands.sty.
– jon
Jan 13 '17 at 17:24
• @jon: In such cases we would give a kingdom for editing comments even after 5 minutes ;-)
– user31729
Jan 13 '17 at 17:28
• @TimothyTruckle never use \include  for including definitions, it should only be used after \begin{document} Jan 14 '17 at 11:47

The simplest way would be to just place your common macro definitions into a separate .tex file an \input 1 this in the preamble of all documents.
You can also just make your own package. The only differences (if you don't want to use package options with it) are to name it somename.sty and to add \ProvidesPackage{somename} as first macro. Then load it using \usepackage{somename} instead of \input.
1) no, do not use \include for this