Подтвердить что ты не робот

Как центрировать вывод LaTeX в полной ширине текста

Я использую tufte-handout (http://mirrors.ibiblio.org/CTAN/macros/latex/contrib/tufte-latex/sample-handout.pdf), чтобы создать небольшой отчет в латексе. У меня есть файл code.Rnw, что я вязать в code.tex. Ниже мой код. Rnw:

\documentclass[12pt,english,nohyper]{tufte-handout}
\usepackage{longtable}
\usepackage{geometry}

\begin{document}

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

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

<<echo=FALSE,results='asis'>>=
fname='plot1.pdf'
pdf(fname,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:hist}MPG vs CYL in MTCARS 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(mtcars[1:20,1:4], label ='tab:mtcars',caption ='This is the mtcar dataset head.',align = c("rr|lr|r"))

print(x.big, tabular.environment ='longtable', floating = FALSE, include.rownames=FALSE)
@

\end{document}

Это приводит к следующему выводу:

this is my output

То, что я пытаюсь сделать, - разрешить центрирование вывода xxtable (Таблица 1) по всему тексту. По умолчанию в пакете tufte-handout он, по-видимому, центрирует таблицу в левом немаржине.

Я консультировался с несколькими источниками, включая те, которые указаны в первом предложении этого текущего сообщения. Согласно этой ссылке, "Полные рисунки и таблицы ширины страницы могут быть размещены в средах с цифрами * или таблицами". Я не уверен, как это сделать, учитывая, что я также вписываю этот отчет.

4b9b3361

Ответ 1

Вы можете обойти эту проблему, обернув longtable в среде tufte fullwidth. Обходной путь также требует небольшого взлома (в строке 2), чтобы исправить hsize, но он работает по назначению.

\begin{fullwidth}
\makeatletter\setlength\hsize{\@[email protected]}\makeatother
<<echo=FALSE,results='asis'>>=
x.big <- xtable(mtcars[1:20,1:4], label ='tab:mtcars',caption ='This is the mtcar dataset head.',align = c("rr|lr|r"))

print(x.big, tabular.environment ='longtable', floating = FALSE, include.rownames=FALSE)
@
\end{fullwidth}