I have a large document with many instances of


for including external content in my main.tex file. I'm now in the rough draft stage of editing, so I'm modifying many of these disparate files. It would be really helpful if the name of the file containing the content for a given page were printed at the top (or in the running head) of that page. This would make it easier to locate the place in the source that I want to edit while reading the draft pdf document.

In the past I would sometimes just add a print statement above each input statement, and sometimes even used the ifthenelse package to make sure those lines only appeared in draft mode, but that seemed like a pretty ugly hack.

Is there an option for draft mode that does this?

This TSE question/answer is helpful; at least it shows how to get the \input command to reveal the filename at the location in the pdf where the inserted content begins and ends. However, if the input file produces many pages of content, it's a pain to search the pdf for the location where that input statement was called.

This TSE question/answer goes even further in that direction and is also very helpful.

I think the best solution would be to display the source file line numbers, as in this answer, and also display the source file name at the top (or running head) of the page.

I suppose an alternative way to go would be to use some fancier editor feature that would allow me to click somewhere on the pdf and have the editor navigate to the corresponding place in the source file. Does anyone using emacs and pdflatex have something like that working? (I don't want to switch editors.) If so and if it wasn't too hard to get configured, could you please share some pointers/instructions or links to resources explaining how to do this?


1 Answer 1


The draftinputlines package does exactly what I want!

To use it, put the draftinputlines.sty file in the same directory as your main.tex source file, then add (for example) the following to your main.tex:

\usepackage[ headfootpackage=fancyhdr, hijackboth=true, dilinputfiles=true, inputfilesrule=false, ]{draftinputlines}

Works like a charm. Thanks Seamus! You are a rockstar!!

You must log in to answer this question.

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