Using TEX root in child document to compile parent document
Often, I construct LaTeX or knitr documents as child-parent documents.
For example, a homework might be constructed as
homework1.Rnw which contains
After initial construction of
homework1.Rnw to include the child documents,
I rarely have need to open this parent document.
Instead, I typically am adding or modifying existing content in one of the
When I want to compile the document, I need to open the parent document and then compile it or, if the parent document is already open, I need to switch over to the tab for the parent document.
What happens more frequently is that I accidentally try to compile the child document which doesn’t work and produces extraneous auxiliary files.
An easy fix is to set the parent document in the child document. To do this use
%!TEX root = homework1.Rnw
as the first line in the child document. Now when you attempt to compile the child document, this line will tell the compiler to instead compile the parent document.
Overall this is an easy fix that I have done countless times, but I inevitably forget what the fix is and need to search for it. Placing it here means I can narrow my search using
I hope this is helpful to others. Then when you try to c
blog comments powered by Disqus