Initial commands can appear only before the \documentclass
line.
\begin{filecontents}
{<file-name>}
<file-contents>
\end{filecontents}
The filecontents
environment is intended for bundling within a
single document file the contents of packages, options, or other
files. When the document file is run through LaTeX2e the body of
this environment is written verbatim (preceded by a comment line) to a
file whose name is given as the environment's only argument. However,
if that file already exists then nothing happens except for an
information message.
Only normal ASCII text characters (7-bit visible text) should be
included in a filecontents
environment. Anything else, such as tab
characters, form-feeds or 8-bit characters, should not be included in a
filecontents
environment.
Tabs and form feeds produce a warning, explaining that they are turned into spaces or blank lines, respectively. What happens to 8-bit characters depends on the TeX installation and is in general unpredictable.
The filecontents
environment is used for including LaTeX files.
For other plain text files (such as Encapsulated PostScript files),
you should use the filecontents*
environment which does not add a
comment line.
These environments are allowed only before \documentclass
. This
ensures that any packages that have been bundled in the document are
present when needed.