Skip to content

Instantly share code, notes, and snippets.

@yihui
Created May 25, 2012 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yihui/2790354 to your computer and use it in GitHub Desktop.
Save yihui/2790354 to your computer and use it in GitHub Desktop.
I love Sweave
\documentclass{article}
\DefineVerbatimEnvironment{Sinput}{Verbatim}{xleftmargin=2em,
fontsize=\footnotesize, fontshape=sl}
\DefineVerbatimEnvironment{Soutput}{Verbatim}{xleftmargin=2em,
fontsize=\footnotesize}
\fvset{listparameters={\setlength{\topsep}{0pt}}}
\renewenvironment{Schunk}{\vspace{\topsep}}{\vspace{\topsep}}
\begin{document}
<<setup, include=FALSE>>=
render_sweave()
@
The quick brown fox jumps over the lazy dog the quick brown fox jumps over the
lazy dog the quick brown fox jumps over the lazy dog.
<<test>>=
1+1
rnorm(30)
@
The quick brown fox jumps over the lazy dog the quick brown fox jumps over the
lazy dog the quick brown fox jumps over the lazy dog.
\end{document}
\documentclass{article}
\usepackage{Sweave}
\begin{document}
This is how knitr looks like:
<<knitr-block, foo=render_latex()>>=
1+1
rnorm(5)
@
This is how Sweave looks like:
<<sweave-block, foo=render_sweave()>>=
<<knitr-block>>
@
<<setup-preamble, include=FALSE>>=
render_latex()
set_header(highlight = knitr:::.header.hi.tex)
@
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment