I'm not sure about Herbert's script "working in one pass for recursive calls." In my interpretation of recursive, I assumed that we would want it to work in one call if one of the input*.tex files themselves contains an \input{} request.
I would have made a comment above to ask about this, but I don't have the reputation.
I created a script with gawk using the same execution syntax:
#! /bin/gawk -f
BEGIN{
FS="\\input{|}"
}{
regex="(%*)(.*)\\input{(.*)}";
if(match($0,regex,a)){
file = a[3];
if(a[1]==""){
match(file,".tex",b);
if(RLENGTH<0){
system("./recursiveInput.awk "file".tex");
}
else{
system("./recursiveInput.awk "file);
}
}
}
else{
print $0
}
}
This has the advantages that:
- it is truly recursive in one-pass (in my interpretation)
- it avoids the use of the perl
chomp() and chop() which produced the undesired effect (in my case) of not faithfully reproducing blank lines (used sometimes in TeX for paragraph delineation)
- It ignores lines with a
% before the \input{} statement, these are lines for which the \input{} command is commented out.
This has the disadvantages that:
- I only implemented it for the
\input{} and not the \include{} statements
.texfile. The issue is the following. I have different files in sub-directories in a recursive manner and hence I cannot upload these individual files since the directory structure in the input command is on the local folder on my computer. I could of-course put these manually but I thought if there would be a way out similar to the .bbl file for the bibliography. – Jul 05 '12 at 05:09