16

I'm having troubles with LuaLaTeX and the listings package: the former doesn't seem to accept me performing \lstinputlisting on a filename that doesn't have an extension.

Minimal example:

Makefile:

hello: hello.c
    cc -o hello hello.c

test.tex:

\documentclass[a4paper]{article}
\usepackage{listings}
\begin{document}
\lstinputlisting{Makefile}
\end{document}

pdfLaTeX is successful, LuaLaTeX displays the following error:

! Package Listings Error: File `Makefile(.tex)' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: tex)

Enter file name:

I'm using the freshest versions from TeXLive 2012 (pdfTeX 3.1415926-2.4-1.40.13, LuaTeX beta-0.70.2-2012052410).

What's the trouble?

2

2 Answers 2

15

The problem has been mentioned on the luatex mailing list: http://tug.org/mailman/htdig/luatex/2013-February/004042.html

The problem is that LaTeX is using \openin and \ifeof to test for the existence of a file and this test fails for files without extensions (despite the fact that the (primitive) \input itself would work).

The problem is not confined to luatex: In miktex your example fails with pdflatex too.

With luatex there is a work around: \openin accepts arguments with braces and this seems to protect the file name. So you can use \lstinputlisting{{Makefile}}.

1
  • As far as I can see the workaround with two {{/}} doesnt work anymore with current luatex. Commented Dec 5, 2019 at 23:07
1

I use MiKTeX.

To correct this issue, I add a dot after the Makefile filename:

\lstinputlisting{Makefile.} 

References: MiKTeX and miktex-users

1
  • 1
    Interesting. Unfortunately, it seems that this works with neither pdfLaTeX nor LuaLaTeX on Linux. Commented Nov 13, 2013 at 21:24

You must log in to answer this question.

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