I have a listing that I use to display some code. I use filecontents to specify the content and lstinputlisting to display it.

The resulting pdf looks ok (used PDFLaTex), but above my code I get:

%% LaTeX2e file ‘[]’
%% generated by the ‘filecontents’ environment
%% from source ‘[]’ on 2016/12/29.

any way to get ride of this ?

  • 2
    Use filecontents* instead of filecontents. Commented Dec 29, 2016 at 10:30
  • 1
    Or tell listings to ignore the first lines with the firstline option. Commented Dec 29, 2016 at 14:45
  • @PeterGrill but that would force it to span two columns ? (I use a two columns layout)
    – Vince
    Commented Dec 29, 2016 at 19:45
  • @UlrikeFischer works :) would be happy to valid the answer, if provided as such
    – Vince
    Commented Dec 29, 2016 at 19:46
  • 1
    What do you mean about spanning two columns? The filecontents environment only writes its content to an external file, there is nothing that can span two columns. The starred version of the environment writes a file without the header you mention. Commented Dec 29, 2016 at 20:06

1 Answer 1


As mentioned by Peter in his comment you can avoid to get the preamble in a file generated by a filecontents environment by using the starred version of filecontents. If this is not possible you can suppress the starting lines with the firstline option:






enter image description here

You must log in to answer this question.

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