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
.
While the ideal aims to be
write your document and then only change the class and options to the loaded packages in order to adapt it to whatever printing style you want
it is quite difficult to attain it for various reasons.
Printing styles often require parts of the document to be in different order. For instance, AMS classes want the abstract
to come before \maketitle
, while the standard classes want it after \maketitle
.
Line and page breaks are usually very different when changing the class, so any adjustment made for one (say a \linebreak
or \pagebreak
command) can be disastrous with another.
Some publishers (among which arXiv) prohibit the usage of some packages or provide a list of the only admitted ones; these proscription lists differ among publishers, ça va sans dire.
Thus if you need for your paper the package extrapack
that publisher Foo allows, but the public site Bar doesn't, you have a problem. You may be able to emulate the workings of extrapack
for submitting the paper to Bar, but that code won't be so nice for Foo.
There is another problem, though. You can't send the paper to Foo and to Bar telling them to compile it with the command line
pdflatex "\def\Foo{YES}\input{TMM-paper}"
as your file starts with
\ifdefined\Foo
\documentclass[<options>]{foopapers}
<packages for Foo>
<special code for Foo>
\else
\documenclass[a4paper]{article}
<packages for Bar>
<special code for Bar>
\fi
because both publishers will probably rely on an automated typesetting process at least for validating the submission.
A different strategy might be to have the paper text in a file TMM-paper.tex
and two other files for the submissions
% File TMM-paper-foo.tex
\documentclass[<options>]{foopapers}
<packages for Foo>
<special code for Foo>
\begin{document}
\input{TMM-paper}
\end{document}
% File TMM-paper-foo.tex
\documenclass[a4paper]{article}
<packages for Bar>
<special code for Bar>
\begin{document}
\input{TMM-paper}
\end{document}
but this won't work if one of the publishers requires the submission to consist of only one file. And, if the two classes require elements to be in different orders, … Oh, wonderful!
Is it impossible, then?
You're not without hope and most often the strategy of having the text in one file to which you can just add the right preamble and do only minor changes (for the position of the abstract or for adding keywords and so on) will work.
Above all, when you submit a paper to a publisher, never add hints for line or page breaking, nor absolute dimensions for figures or tables (only relative ones to \columnwidth
, for instance).
These may be added for the arXiv version, of which you know precisely the final output format, since their system doesn't touch the contents, but only validates the file from a formal point of view (it compiles without errors). Of course such adjustments cause a fork in your text file; nothing to be really worried about if you use, or maybe abuse, comments in your file.
Best Answer
there is a third possibility and for projects the best one: put all in a
texmf
directory which is located inside your documents directory. Then do aexport TEXMFHOME=texmf
before runningpdflatex
or something else and thetexmf
tree will be searched first.Inside this local
texmf
you must have the same TeX Directory Structure as usual: http://tug.org/tds For a localtexmf
tree you do not need to runtexhash
because files are searched recursively in that tree