If I compile the above code (using XeLaTeX, TeXStudio, Windows) I get a nicely typeset A5-paper article. If next I change a5paper to twocolumn and compile again, nothing changes. I get the warning

File `exampleclass.cls' already exists on the system.

So I suppose there is some temporary cls.-file created which cannot be edited. How do I change this behaviour?

  • 1
    it's just created in the current directory, you can simply delete it if you have edited the content and want latex to re-write it. Mar 3 '18 at 10:19
  • @David Carlisle Ah ok, and since I had not saved my above document, TeXStudio indeed created temporary files.
    – user157036
    Mar 3 '18 at 10:21
  • oh so texstudio saves the file somewhere strange and runs latex there? A bit strange but OK:-) Mar 3 '18 at 10:24

Package filecontents allows the overwriting of files:


LaTeX kernel

The original environment filecontents from the LaTeX kernel is documented in source2e:

The environment filecontents is intended for passing the contents of pack ages, options, or other files along with a document in a single file. It has one argument, which is the name of the file to create. If that file already exists maybe only in the current directory if the OS supports a notion of a "current directory" or "default directory") then nothing happens (except for an information message) and the body of the environment is bypassed. Otherwise, the body of the environment is written verbatim to the file name given as the first argument, together with some comments about how it was produced.

The environment is allowed only before \documentclass to ensure that all packages or options necessary for this particular run are present when needed. The begin and end tags should each be on a line by itself. There is also a star-form; this does not write extra comments into the file.


Package filecontents lifts the restrictions:

  • It allows the overwriting.
  • The place for the environment is not restricted to before \documentclass. It can also be placed in the preamble or after \begin{document}.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy