1

i want to save a text to a file using the filecontents package. Here is the source code:

\begin{filecontents}[overwrite]{test.lst}
Hello World!
\end{filecontents}

A file "test.lst" is created, but it is empty. If I use the source code

    \begin{filecontents*}[overwrite]{test.lst}
Hello World!
\end{filecontents*}

then the header

%% LaTeX2e file `test.lst'
%% generated by the `filecontents' environment
%% from source `javaprogrammierung' on 2021/04/08.
%%

is written into the file, but not the text "Hello World!".

Can someone help me, why no text is written? I am using MacTeX 2021.

Thanks in advance for any help!

Soener

Soener
  • 41

1 Answers1

3

The manual of the filecontents package states the following on the first page (see also daleif's comment below your question).

enter image description here

Notice The version of LaTeX released in Fall 2019 incorporates all of this package’s functionality (and more) into the LaTeX kernel itself. As a result, there is no longer a need for the filecontents package. Please use the new, built-in filecontents environment instead.

Update your LaTeX installation (if necessary) and start with the following minimal example (taken from the manual) and tell us if you still have problems.

\documentclass{article}

\begin{document}

\begin{filecontents}{myfile.tex} This text gets written to \texttt{myfile.tex}. \end{filecontents}

\end{document}