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}%
}
  • Are you using \input inside floats as well? – Werner May 22 '13 at 4:53
  • possibly, assume yes. – Nicholas Hamilton May 22 '13 at 4:57
  • in fact, definitely yes. – Nicholas Hamilton May 22 '13 at 4:58
  • Do the \inputed files contain verbatim content? – Werner May 22 '13 at 4:59
  • 1
    LaTeX's \input is set up to allow both plain TeX and LaTeX-like syntaxes. You probably want to redefine \@iinput, which is used internally with the LaTeX-like version. – Joseph Wright May 22 '13 at 6:01
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.

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.