我最初在 StackOverflow 上发布了此文章(https://stackoverflow.com/questions/31359737/table-environment-from-xtable),但有人建议我将其发布在这里。
我在 LaTeX 中使用 tufte-handout documentclass(http://mirrors.ibiblio.org/CTAN/macros/latex/contrib/tufte-latex/sample-handout.pdf)。我试图创建一个横跨整个页面(而不仅仅是无边距页面)的表格,并且可以分页。以下是我的代码:
\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}
(第一页的)输出如下:
但是,我希望表格位于整个页面的中心(而不仅仅是页面的非边距部分),以便输出看起来更像这样:
这可能吗?正如我在 StackOverflow 论坛上看到的那样(https://stackoverflow.com/questions/31359737/table-environment-from-xtable),我尝试了一些选项,但没有成功。我尝试硬编码打印 xtable 的指定水平位置,但并没有取得太大成功。例如,有没有办法指定 xtable 打印在页面左侧 3 英寸处?因为如果是这样,我会认为这是一个解决方案;它不必完全位于中心,但硬编码至少可以让我更接近中心。