TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
some people don't know how to use tar or zip. filecontents keeps everything together in one .tex file. – barbara beeton Mar 26 '13 at 22:29
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 Mar 26 '13 at 22:31
I would add that some computing environments forbid binary data breaching firewalls, whereas ASCII is, with caveats, allowed – Steven B. Segletes Mar 26 '13 at 22:35
Example for an .eps file inclusion. : tex.stackexchange.com/questions/47341/… – percusse Mar 26 '13 at 22:37
up vote 20 down vote accepted

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.

share|improve this answer
Wow, in 1993 they already prepared latex2e for use with stackexchange ;-) – arney Mar 26 '13 at 22:55
@arney well we were probably thinking more of comp.text(.tex) but it's the same questions, just recycled:-) – David Carlisle Mar 26 '13 at 23:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.