I really need help. Here is the problem:
I'm writing my dissertation using a LaTeX template (http://www.latextemplates.com/template/masters-doctoral-thesis). The template is a parent file with multiple chapters as children. For some of the chapters, I want to include objects and output from R, whereas for other chapters (e.g., Introduction) I don't want to use R. For the chapters without R, I've created the .TeX files as part of the template.
I'm using knitr to create .TeX files with R objects and output. I want the .Rnw files to be included as child .TeX files into another child .TeX file that belongs to the larger parent .TeX file. The parent-child structure works for my .TeX files as part of the template using \input{}. However, I'm having trouble getting the .TeX files created from the .Rnw files to be included as child .TeX file in an another child file.
I've seen resources for combining .Rnw files as child files of a larger parent .Rnw file, but they do not address my issue (unless I am reading them the wrong way).
I knitted the .Rnw file into .TeX, then copy the body of document generated in the child file, and copy the rest in LateX classfile (that is the document where you declare the packages that will be used in the main document), but I get the following error message:
you can't use '\spacefactor' in vertical mode \tableofcontents
Additionally, my table of contents on the final outputs do not print properly at all.
\@somethingin a place where@is not a letter. So you need to move that somewhere else or surround it with\makeatletter ... \@something.... \makeatother– David Carlisle Nov 27 '14 at 12:56.clsfile,.teXfile and.Rnwfile. – Franckess Nov 27 '14 at 16:02.Rnwfile rather than a.texfile. Just because you don't have R code in some chapters doesn't mean that you can't still save it as an.Rnwfile and process it withknitr. Doing so will just be vacuous. Then you can avoid copying and pasting stuff. My answer here should solve your use case. – Adam Liter Nov 27 '14 at 23:53\usepackage{listings}then adjust it according to the preamble of the .tex file when the .Rnw is knitted. Everything is looking good now :) – Franckess Nov 28 '14 at 14:00.texfiles to.Rnwfiles and replace all of the\inputcommands to, for example,<<child-demo, child='Chapters/Chapter1.Rnw'>>=@, then it will work just fine. – Adam Liter Nov 28 '14 at 16:48.Rnwfile inclusion. – R. Schumacher May 10 '15 at 02:49