My goal is to combine several documents into one, so maybe someone can recommend a different solution. More specifically, I need to input about 20 files in a master file, all from line 4 to the second-to-last line, inclusive (I am excluding the \documentclass tag, an \input{header} tag, and \begin and \end{document} tags).
I would like to have a command, very similar to @mpg's answer here, except where the second number is relative to the number of lines in the file. For instance, something like
\partialinput{4}{-1}{pitest}
would be great. Or maybe
\partialinput{4}{\linenumber{pitest}-1}{pitest}
or similar (where \linenumber could be some command that gets the number of lines in the argument file). I would prefer not to use `subfiles', as that would require changing all the headers of the individual files. So, my questions are,
- Is there a command that gives back the number of lines in another file, or
- Can the
\partialinputcommand be modified to include all but the last line in a document?
I'm not very proficient at TeX or e-TeX, so the structure of the \partialinput command is not clear to me. I initially thought that making the counter look one line ahead and stop when it reaches the end would do it, but again, I don't know enough TeX to make that happen.
partialinputusing a suitable set of standard utilities such asheadandtailcalled bywrite18. Orsed: https://tex.stackexchange.com/a/4908/28808 (this answer would be quite easy to modify) – Chris H Jun 16 '17 at 21:31\inputthem. – David Carlisle Jun 16 '17 at 21:34catchfilebetweentagsmight help – Jun 16 '17 at 21:53write18will have the same result.@DavidCarlisle because I would like each of the smaller documents to be typeset separately - I suppose this is just an organizational and navigational preference.
@ChristianHupfer this is what I ended up using, although I was put off by it because somewhere (can't find the question anymore) @egreg implied that
– Jānis Lazovskis Jun 17 '17 at 21:01catchfilebetweentagsnever works as expected. But it seems to work for me.