I would like to include part of the contents of a .tex file into a different .tex file. I don't have the option of modifying the file to include. The file to include may change so simply copying and pasting the part I need is not ideal.
Essentially, I'm wondering if there is something that would work like
\input[start-end]{file.tex}
where start
and end
are the first and last lines to include from the file?
Best Answer
Here is an approach in pure TeX (well, e-TeX). The main idea is: to select a range of lines in a file, sed is overkill, TeX is more than enough. As a bonus, no temporary file is needed.
I think/hope this approach is robust, mostly thanks to e-TeX's
\readline
. See the included test file for potential edge cases that do work.