Often, I construct LaTeX or knitr documents as child-parent documents. For example, a homework might be constructed as homework1.Rnw which contains links to problem1.Rnw and problem2.Rnw. 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 child documents.

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.

blog comments powered by Disqus


13 October 2021