[Tex/LaTex] How does \usepackage work

packages

I have a style file which includes another .sty file
with \usepackage. Everything works fine. Since this is a
small file written by myself I decided to insert it verbatim
at the same place were I use \usepackage in the surrounding
file. But this results in errors. This gives raise to
the general question in the title. More specific:

What do I have to do to make such an inclusion work?

Best Answer

\usepackage just arranges that @ is a letter, checks the package name against any \ProvidesPackage in the included file and then does \input.

Related Question