0

I originally posted about this on StackOverflow (https://stackoverflow.com/questions/31359737/table-environment-from-xtable), but it was recommended for me to post it here instead.

I am using the tufte-handout documentclass in LaTeX (http://mirrors.ibiblio.org/CTAN/macros/latex/contrib/tufte-latex/sample-handout.pdf). I am trying to create a table that spans the whole page (not just the non-margin page), and can page break. Below is my code:

\documentclass[12pt,english,nohyper]{tufte-handout}
\usepackage{longtable}
\usepackage{geometry}
\usepackage{tabularx} % Make sure this is in there

\begin{document}

<<include=FALSE>>=
library(ggplot2)
library(xtable)
@

\centerline{\Large\bf This is my Main Title about Diamonds}

<<echo=FALSE,results='asis'>>=
fname='plot1.pdf'
pdf(fname,width=4,height=4)
print(qplot(depth,price,data=diamonds))
{dev.off();invisible()}
cat(sprintf('\\begin{marginfigure}
\\includegraphics[width=0.98\\linewidth]{%s}
\\caption{\\label{mar:hist}DEPTH vs PRICE in DIAMONDS dataset.}
\\end{marginfigure}',sub('\\.pdf','',fname)))
@

This is the paragraph in my report. This is the paragraph in my report. This is the paragraph in my report. This is the paragraph in my report. This is the paragraph in my report. This is the paragraph in my report. This is the paragraph in my report.

This is the paragraph in my report. This is the paragraph in my report. This is the paragraph in my report. This is the paragraph in my report. This is the paragraph in my report. This is the paragraph in my report. This is the paragraph in my report. This is the paragraph in my report. This is the paragraph in my report. This is the paragraph in my report. This is the paragraph in my report. 

\bigskip{}

<<echo=FALSE,results='asis'>>=
x.big <- xtable(diamonds[1:100,1:4], label ='tab:mtcars',caption ='Diamonds have an interesting dataset.',align = c("rr|lr|r"))
print(x.big, tabular.environment ='longtable', floating = FALSE, include.rownames=FALSE)
@

\end{document}

And the output (of the first page) looks like:

My output right now

However, I would like the table to be centered across the whole page (not just the non-margin part of the page), so that the output would look more like:

My goal output

Is this possible? As can be seen on the StackOverflow forum where I originally posted (https://stackoverflow.com/questions/31359737/table-environment-from-xtable), I tried some options unsuccessfully. I have not been too successful trying to hard-code a specified horizontal position of the printed xtable. For instance, is there any way to specify that the xtable be printed 3 inches from the left side of the page? Because if so, I would consider that a solution; it does not have to be perfectly in the center, but hard-coding would allow me to at least get it closer.

  • That's not a .tex file. At least, not all of it is. Some of it is. Don't use \centerline. Don't use \bf. And don't manually format things like titles. Use \maketitle and specify your plain text title without markup as \title{My title}. The code relevant to your question is obfuscated in some way? Or processed in some way? Not sure. – cfr Jul 12 '15 at 23:48
  • @cfr Thank you. I am sorry I forgot to specify, the code above is .Rnw file. I then use knitr and do knit(code.Rnw). This creates the code.tex file. Do you believe there is a method to shift the table over the right by a specified amount? Thanks again... – luckButtered Jul 13 '15 at 1:56
  • Wouldn't know. Sorry. I know nothing about knitr. – cfr Jul 13 '15 at 1:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.