18

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?

Werner
  • 603,163
arney
  • 2,023
  • 4
    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
  • 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 Mar 26 '13 at 22:31
  • 4
    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. : http://tex.stackexchange.com/questions/47341/can-you-embed-an-image-so-it-doesnt-need-to-be-stored-as-a-separate-file – percusse Mar 26 '13 at 22:37

1 Answers1

19

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.

David Carlisle
  • 757,742