# importing a portion of another tex file

I have several papers that have full preambles including cover pages, package include statements, etc. I am compiling the papers into one long book that has chapters and would like to import that papers as individual chapters. In order to do this (because the formatting of the book is different than the papers), I need to skip the preamble and start with the first section of each paper. Is there a way to import each one starting from a particular point in the tex file?

Let me describe the setup so it's a bit clearer: I have each paper that I created in LyX. The master document is a tex file provided to me that has all the appropriate formatting etc. That is, the master file is not a LyX file but a usual tex file which imports the individual chapters.

The reason I want to do this (instead of manually just removing the preamble) is in the event I make changes, I don't want to have to make changes to two files, I would like them to be synced.

• `\include` just includes the whole file. So you could move the common part to a file and make shell files both for the paper and for the book. – Thruston Jul 29 '16 at 17:39
• @Thruston: that's a good idea in principal, the issue is i use LyX as my editor most of the time and it automatically throws in a preamble. i suppose i could start using texstudio for everything but i like the WYSIWYG-esque nature of LyX. – Alex Jul 29 '16 at 17:42
• Hmmm - looks complicated - wiki.lyx.org/FAQ/Multidoc – Thruston Jul 29 '16 at 17:48
• Will the `combine` package help you? mirror.hmc.edu/ctan/macros/latex/contrib/combine/combine.pdf . Also see tex.stackexchange.com/questions/155739/… – Ethan Bolker Jul 29 '16 at 17:50
• When you include a file in LyX, the master document's preamble is used. So I actually think it works exactly how you want. Did you test? Perhaps I misunderstood: go to Insert > File > LyX document, compile and test that the master's preamble was used. Then open the LyX document on its own and compile that. The child's preamble should be used (if not, then make sure that in the child .lyx file "Select default master document" is unchecked and then I'm sure the child's preamble is used. – scottkosty Jul 29 '16 at 17:55