[texhax] filecontents in own environment

Arno Trautmann Arno.Trautmann at gmx.de
Wed May 25 11:26:04 CEST 2011


Hi all,

I want to use a filecontents-environment in my document via the
filecontents package. This works fine, but I want to add some more
markup, especially I want to have some standard code /inside/ the
filecontents and additional standard code /after/ the filecontent, but
inside my own environment. I thought to try something like

\NewDocumentEnvironment{myfilec}{m}
  {
  \begin{filecontents}{#1}
    %code inside the external file, e.g.
    \documentclass{minimal}
    \begin{document}
  }
  {
    %code at the end of external file, e.g.
    \end{document}
  \end{filecontents}
    %code executed after external file is written, e.g.
    \include{#1}
  }

Now, this appearently did not work, as filecontents searches for
\end{filecontents} and is not happy if not found in the source code. I
also was not able to change it even to another name using \def or \let
without complications.

So, does anyone have an advice how I could realize what I want to, or at
least some steps of it? I'd be happy about any hints,

cheers
Arno

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://tug.org/pipermail/texhax/attachments/20110525/c9da0670/attachment.bin>


More information about the texhax mailing list