Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the Tufte-Latex class in Sweave

I must confess that today is my first day using either Sweave or LaTeX. Yes, it's true. I realized today that my "before 40" bucket list was not going to resolve itself in the absence of my involvement. And like so many men of my generation, learning Sweave and LaTeX is on my bucket list.

So with that long preamble, I have a very nice first Sweave document:

\documentclass{article}
\begin{document}
\title{Look Mom! I'm doing \LaTeX}
\author{JD Long}
\maketitle
\section{Where I get both funky and fresh}
<<make some randomness>>=
  set.seed(12)
  t <- rnorm(100)
@
and an example plot
\begin{center}
<<fig=TRUE,echo=FALSE>>=
  plot(density(t))
@
\end{center}
This is a very simple example of how we might get started with Sweave. You know what comes next, right? That's right... Lorem Ipsum, ladies! 

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin sed sem est. Pellentesque massa magna, ullamcorper eget lacinia sit amet, dignissim ac leo. Fusce hendrerit elit vitae lacus mollis suscipit. 
\end{document}

Which produces this wonderful output:

enter image description here

So that much is great. But what I really would like to do is start bringing in wonderful LaTeX classes like the Tufte-LaTeX class which, from what I understand, basically turns my documents into brilliant, inspired works of art.

So how would I bring the Tufte-LaTeX business into my Sweave document and use it to make my documents more magical?

like image 502
JD Long Avatar asked Nov 09 '11 19:11

JD Long


1 Answers

I kind of like this as my standard header wrapped around your document:

\documentclass{tufte-handout}
\usepackage{amsmath}  % extended mathematics
\usepackage{booktabs} % book-quality tables
\usepackage{units}    % non-stacked fractions and better unit spacing
\usepackage{multicol} % multiple column layout facilities
\usepackage{lipsum}   % filler text
\usepackage{fancyvrb} % extended verbatim environments
  \fvset{fontsize=\normalsize}% default font size for fancy-verbatim environments
\usepackage{xspace}

I would note you should not put any markup in things like the title or author, as tufte-handout really doesn't do too well with it:

enter image description here

The Tufte classes are easily installed via TeXLive as the "tufte-latex" package, which includes the necessary material and some examples, if I recall correctly.

like image 64
James Howard Avatar answered Sep 25 '22 06:09

James Howard