5

I have a master document, and use many input{...} commands to compile the total document from many parts.

I would like to mark on the working document, the start of each new input, and, what the filename was at that point.

I could renew the \input{..} command, but I do not want the mark to disrupt what would otherwise be the standard ouput, ie, the mark should be an underlay / watermark.

Is there a package that does this, I am thinking something similar to what the showkeys package does.

I had the following in mind, to create a label whenever input is used, relying on showkeys do do the underlying marking on the document, but it isn't working:

\let\oldinput\input
\newcounter{inputcounter}\setcounter{inputcounter}{0}
\renewcommand{\input}[1]{%
    \stepcounter{inputcounter}%
    \label{inp:\theinputcounter:#1}%
    \oldinput{#1}%
}
egreg
  • 1,121,712

1 Answers1

4

The LaTeX definition of \input is designed to allow both the standard LaTeX braced-argument syntax

\input{filename}

and the original primitive syntax

\input filename % Space-terminated

However, you've redefined it such that it will only work with the LaTeX syntax. If you take a peek at the definition of \input, you'll find that the LaTeX syntax branch is handled by \@iinput. So that's the place to make a change

\makeatletter
\newcounter{inputcounter}
\let\old@iinput\@iinput
\renewcommand{\@iinput}[1]{%
    \stepcounter{inputcounter}%
    \label{inp:\theinputcounter:#1}%
    \old@iinput{#1}%
}
\makeatother

This assumes that you don't want to track use of the primitive syntax use, which is probably being used only by cross-format packages like pgf.

Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
  • What would be the best way to place a horizontal rule (dashed) the width of the page, at the label location, without shifting any of the subsequent content down in any way, ie, non-disruptive? – Nicholas Hamilton May 22 '13 at 20:11