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. Commented Mar 3, 2018 at 10:19
  • @David Carlisle Ah ok, and since I had not saved my above document, TeXStudio indeed created temporary files.
    – user157036
    Commented Mar 3, 2018 at 10:21
  • oh so texstudio saves the file somewhere strange and runs latex there? A bit strange but OK:-) Commented Mar 3, 2018 at 10:24

1 Answer 1


LaTeX after 2019-10-01

The LaTeX kernel has extended its filecontents environment to support an optional argument, see LaTeX News, Issue 30, LaTeX releas 2019-10-01.

If the option force or its alias overwrite is specified, the environment follows the behavior of package filecontents and allows that the file is overwritten.

Example (without package filecontents):


LaTeX before 2019-10-01

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}.
  • Package filecontents refuses to be loaded (log says "Package filecontents Warning: This package is obsolete. Disabling it"). Is there any workaround? Commented Sep 12, 2023 at 16:31
  • 1
    @LucasSoares I have updated the answer for the new filecontents environment of the LaTeX kernel 2019-10-01. Commented Sep 15, 2023 at 20:29

You must log in to answer this question.