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

2
  • As always on the site please provide a full but minimal example so we know exactly what you are doing. Note that filecontents is in the kernel, no package needed.
    – daleif
    Commented Apr 8, 2021 at 16:59
  • 1
    Consider accepting the provided answer if it solved the problem. Commented Apr 11, 2021 at 15:10

1 Answer 1

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}
1
  • 1
    Now it works. Thank you.
    – Soener
    Commented Apr 11, 2021 at 12:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .