Does anyone know why the filecontents environment was introduced?

What is the purpose of packing it all in one file, but without using a tarball?

  • 4
    some people don't know how to use tar or zip. filecontents keeps everything together in one .tex file. Commented Mar 26, 2013 at 22:29
  • 2
    Echoing @barbarabeeton's comment (from the source2e documentation, p 361): "The environment filecontents is intended for passing the contents of packages, options, or other files along with a document in a single file."
    – Werner
    Commented Mar 26, 2013 at 22:31
  • 4
    I would add that some computing environments forbid binary data breaching firewalls, whereas ASCII is, with caveats, allowed Commented Mar 26, 2013 at 22:35
  • Example for an .eps file inclusion. : tex.stackexchange.com/questions/47341/…
    – percusse
    Commented Mar 26, 2013 at 22:37

1 Answer 1


It's a natural extension of the ideas of docstrip that extracts comments and writes out the .sty and .cls files of the LaTeX distribution. It could have been written in perl or something but writing it in TeX makes it more portable to anyone who has tex at all.

Note that in 1991-1993 while latex2e was being developed, perl (introduced 1987) and a portable zip (info-zip introduced 1989) were not as commonly installed as they are today. Even now it is much easier to add small .csv data files or local .sty files to examples posted to this site by using filecontents than it is to post them as separate files and have to give instructions about saving and file names, or posting to some other site as a zip or tar file and then hoping people on windows can unpack it.

  • 2
    Wow, in 1993 they already prepared latex2e for use with stackexchange ;-)
    – arney
    Commented Mar 26, 2013 at 22:55
  • 3
    @arney well we were probably thinking more of comp.text(.tex) but it's the same questions, just recycled:-) Commented Mar 26, 2013 at 23:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .