I would like to redefine the \input command so that it also embed the input file to the generated pdf. So far I used the code from thi s question (Mark on document where input starts and what is the filename):
\documentclass{article}
\usepackage{embedfile}
\usepackage{pgfplots}
\usepackage{letltxmacro}
\makeatletter
\LetLtxMacro\latex@iinput\@iinput
\renewcommand{\@iinput}[1]{%
\latex@iinput{#1}%
\embedfile[desc=input file]{#1}%
}
\makeatother
\begin{document}
\input{input-prova.tex}
\begin{tikzpicture}
\begin{axis}
\addplot {x};
\end{axis}
\end{tikzpicture}
\end{document}
This works but it has a problem: when I use other packages as pgfplots my redefinition of \input affect also \input's commands present in the package's source codes and in my final pdf I have all these files embedded..
The second problem is that when I try to add an argument to this command in this way:
\makeatletter
\LetLtxMacro\latex@iinput\@iinput
\renewcommand{\@iinput}[2][input file]{%
\latex@iinput{#2}%
\embedfile[desc=#1]{#2}%
}
\makeatother
\begin{document}
\input[file description]{input-prova.tex}
\end{docmuent}
I get an error...
I know that both problems can be resolved by defining my own command lie this:
\newcommand{\myinput}[2][input file]{%
\input{#2}%
\embedfile[desc=#1]{#2}%
}
but I was wondering if there is a way of doing it without changing the name of the \input command.
\embedfile[desc={#1}]{#2}for the case that the description contains square brackets. – Heiko Oberdiek Oct 10 '13 at 15:48