I have posted on other sites as well, and it did not seem doable for me to accomplish the page-break in the margin notes (instead the text simply falls off the bottom of the page).
Now, I am trying a different approach. I have an xtable (of 26 rows). I am trying to print this xtable in the margins. It will start on the first page, and end on the second page. Hence, I am trying to now page-break this xtable in the margins.
My approach is shown below. If you remove the third (last) chunk, you can see the page format works so far. There is main text, and then there are two figures in the margin.
The third chunk is intended to add the xtable below the two figures in the margin (it should start on the first page and continue to the second page). However, I am receiving an error that values.pdf does not exist (whereas mtcars1.pdf and mtcars2.pdf were successfully created).
Any advice to achieve this (even if another approach is needed) is greatly appreciated!
Code: Select all
\documentclass[12pt,english,nohyper]{tufte-handout}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage[space]{grffile}
\usepackage{geometry}
\usepackage{pgffor}
\usepackage{caption}
\usepackage{calc}
\usepackage{enumitem}
\usepackage{microtype}
\makeatletter
\makeatother
\newcounter{marginresume}
\begin{document}
<<include=FALSE>>=
library(ggplot2)
library(reshape2)
library(xtable)
library(dplyr)
library(stringr)
library(knitr)
@
<<echo=FALSE,results='asis'>>=
fname1="mtcars1.pdf"
pdf(fname1,width=4,height=4)
print(qplot(mpg,cyl,data=mtcars))
{dev.off();invisible()}
cat(sprintf('\\begin{marginfigure}
\\includegraphics[width=0.98\\linewidth]{%s}
\\caption{\\label{mar:myQplot}Plot of MPG and CYL.}
\\end{marginfigure}',sub('\\.pdf','',fname1)))
cat("\\marginnote{\n\n \\bigskip{} \n\n} ")
fname2="mtcars2.pdf"
pdf(fname2,width=4,height=4)
print(qplot(hp, qsec, data=mtcars))
{dev.off();invisible()}
cat(sprintf('\\begin{marginfigure}
\\includegraphics[width=0.98\\linewidth]{%s}
\\caption{\\label{mar:myQplot2}Plot of HP and QSEC.}
\\end{marginfigure}',sub('\\.pdf','',fname2)))
cat("\\marginnote{\n\n \\bigskip{} \n\n} ")
@
This is the main body of text. This is the main body of text. This is the main body of text. This is the main body of text. This is the main body of text. This is the main body of text. This is the main body of text. This is the main body of text. This is the main body of text. This is the main body of text. This is the main body of text. This is the main body of text. This is the main body of text. This is the main body of text.
<<echo=FALSE,results='asis'>>=
myDF = data.frame(vals=runif(26, 1, 10))
row.names(myDF) = letters
fname3="values.pdf"
pdf(fname3,width=4,height=4)
print(xtable(myDF,caption='List of letters and values.',label='tab:lettersVal',align='lr'),floating=FALSE, tabular.environment = "longtable")
{dev.off();invisible()}
cat(sprintf('\\begin{marginfigure}
\\includegraphics[width=0.98\\linewidth]{%s}
\\caption{\\label{mar:myDFPlot}Plot of Letters and Values.}
\\end{marginfigure}',sub('\\.pdf','',fname3)))
@
\end{document}