rstudio / tufte Goto Github PK
View Code? Open in Web Editor NEWTufte Styles for R Markdown Documents
Home Page: https://rstudio.github.io/tufte/
Tufte Styles for R Markdown Documents
Home Page: https://rstudio.github.io/tufte/
Here is a minimal reprex: (Excuse the \
before the backticks marking the chunks, I couldn't figure out how to escape them inside the issue)
I used xelatex
because that was in the template file in RStudio
but it doesn't work without it either.
---
title: "Test"
output:
tufte::tufte_handout:
latex_engine: xelatex
---
\```{r setup, include=FALSE}
library(tufte)
# invalidate cache when the tufte version changes
knitr::opts_chunk$set(tidy = FALSE, cache.extra = packageVersion('tufte'))
options(htmltools.dir.version = FALSE)
\```
\```{r, fig.margin = T}
knitr::kable(
mtcars[1:6, 1:6], caption = 'A subset of mtcars.'
)
\```
First of all, thanks for this excellent package.
Would it be possible to create a notebook output type following Tufte's style? maybe this is possible already, I'm not sure. Notebooks have become all the rage in my peer group because they're an easy way to share both well rendered output and the code that generated it.
Using toc: TRUE in the YAML seems not to work.
If I write the following inline within rmarkdown:
`r tufte::margin_note('To find a list of all the built in datasets you can type `help(datasets)`')`
I get the following error:
Error in parse(text = code, keep.source = FALSE) :
<text>:1:20: unexpected INCOMPLETE_STRING
1: tufte::margin_note('To find a list of all the built in datasets you can type
^
The problem is that the normal scale of \
doesn't seem to work. Nor adding multiple backticks. The only solution I came to is:
`r tufte::margin_note('To find a list of all the built in datasets you can type \x60help(datasets)\x60')`
Which feels like a real hack. Is this the only way of doing it?
Hi,
there seem to be a similar problem with tufte::tufte_html
as with bookdown::html_document2
described in rstudio/rmarkdown#1063. The only difference is that this time sidenotes are affected and are not displayed when the document uses runtime: shiny
. As suggested in the other issue, one can circumvent this by specifying an empty prefix with pandoc_args: ["--id-prefix", '""']
. But I'm wondering whether there is a better solution to this?
Cheers,
Andrzej
MWE:
---
output:
tufte::tufte_html
runtime: shiny
---
# Introduction
A paragraph.^[with a sidenote]
I just tried the knitting the example source from https://github.com/rstudio/tufte/raw/master/inst/rmarkdown/templates/tufte_html/skeleton/skeleton.Rmd
It did not work, I get the following error
pandoc-citeproc: When expecting a product of 2 values, encountered an Array of 3 elements instead
pandoc: Error running filter /usr/local/bin/pandoc-citeproc
Filter returned error status 1
Error: pandoc document conversion failed with error 83
I also installed the latest version of rmarkdown from github instead of the one from CRAN, but the error remained.
Thank you for the new "envisioned" variant, looks great!
Though it seems I can't bring italics in the sidenotes to work. You could reproduce it by this:
`
```{marginfigure}
We know from the first fundamental theorem of calculus that for
```
`
and setting tufte_variant: "envisioned"
. Without the latter, italics do work!
I've already tried tufte_features: ["fonts", "background", "italics"]
with no success.
Cheers.
First, thank you for coding and sharing this template. It's very promising and helpful to academics.
The tufte format uses footnotes to place citations in the margin. When compiling the template in HTML format, the citations indeed appear in the margin--though without a footnote number, which would be a useful feature for scientists.
When compiling the tufte-handout (or tufte-book) template in PDF, citations do not appear in the margin as they do in the latex-tufte template.
I was able to fix this in part with a rudimentary solution, by adding the following to the YAML header.
header-includes:
- \setcitestyle{super}
- \renewcommand*{\citep}[1]{{\cite{#1}}}
- \renewcommand*{\citet}[1]{{\cite{#1}}}
This effectively redefines the natbib \citep
and \citet
commands to use the \cite
commands compatible with tufte-handouts and tufte-book. This solution doesn't adversely impact the margin citations in HTML format. However, it would be nice to still have a textual version of the \citet
that includes a footnote reference (ex: Smith et al. 2000 3).
The Tufte classes appear to rely on natbib. I also tried various solutions with biblatex on the post-processed .tex
file---using nobib
as a documentclass option, or natbib=true
as a package option to biblatex---but I couldn't get these to work.
Altogether, I'm reporting a bug and requesting a feature:
Bug: I expect the tufte-handout and tufte-book PDF outputs to match those of latex-tufte.
Feature: I'd like to request that the HTML can (optionally) output margin citations with a superscript number.
When have the following chunk in my Rmarkdown document:
```{r fig-margin, fig.margin = TRUE, fig.cap = "Test.", fig.width=3.5, fig.height=3.5, cache=TRUE, echo=FALSE}
DiagrammeR::grViz("
digraph DAG {
1,2;
1->2;
}
")
```
it produces a figure in the text, rather than in the margins. Here's my session info:
> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.12.1 (Sierra)
locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] Rcpp_0.12.7 tufte_0.2.5 digest_0.6.10 withr_1.0.2
[5] assertthat_0.1 R6_2.1.3 magrittr_1.5 git2r_0.15.0
[9] evaluate_0.9 httr_1.2.1 stringi_1.1.1 curl_2.0
[13] rmarkdown_1.1 devtools_1.12.0 tools_3.3.1 stringr_1.1.0
[17] rsconnect_0.4.5 yaml_2.1.13 memoise_1.0.0 htmltools_0.3.5
[21] knitr_1.14 tibble_1.2
and I'm modifying the default tufte
Rmarkdown template.
Hi,
after installing the latest version from Github, I get the following error:
pandoc: /home/bayes/R/library/tufte/rmarkdown/templates/tufte_html/resources/tufte-margin_references.css: openBinaryFile: does not exist (No such file or directory)
Error: pandoc document conversion failed with error 1
My YAML header is just this:
---
title: "A title"
author: "Me"
date: "`r date()`"
output:
tufte::tufte_handout: default
tufte::tufte_html: default
---
The PDF file is generated correctly, but when pandoc
tries to compile to HTML I get that error.
I've tried the same file with version 0.2 of tufte (from CRAN) and it worked fine for both formats, so I guess the problem is with this version.
> devtools::session_info("tufte")
Session info ------------------------------------------------------------------
setting value
version R version 3.4.3 (2017-11-30)
system x86_64, linux-gnu
ui X11
language (EN)
collate en_GB.UTF-8
tz America/Sao_Paulo
date 2018-01-11
Packages ----------------------------------------------------------------------
package * version date source
backports 1.1.2 2017-12-13 CRAN (R 3.4.3)
base64enc 0.1-3 2015-07-28 CRAN (R 3.4.0)
digest 0.6.13 2017-12-14 CRAN (R 3.4.3)
evaluate 0.10.1 2017-06-24 CRAN (R 3.4.0)
graphics * 3.4.3 2017-12-07 local
grDevices * 3.4.3 2017-12-07 local
highr 0.6 2016-05-09 CRAN (R 3.4.0)
htmltools 0.3.6 2017-04-28 CRAN (R 3.4.0)
jsonlite 1.5 2017-06-01 CRAN (R 3.4.0)
knitr 1.18 2017-12-27 CRAN (R 3.4.3)
magrittr 1.5 2014-11-22 CRAN (R 3.4.0)
markdown 0.8 2017-04-20 CRAN (R 3.4.0)
methods * 3.4.3 2017-12-07 local
mime 0.5 2016-07-07 CRAN (R 3.4.0)
Rcpp 0.12.14 2017-11-23 CRAN (R 3.4.2)
rmarkdown * 1.8.6 2018-01-11 Github (rstudio/rmarkdown@dbb750b)
rprojroot 1.3-2 2018-01-03 CRAN (R 3.4.3)
stats * 3.4.3 2017-12-07 local
stringi 1.1.6 2017-11-17 CRAN (R 3.4.2)
stringr 1.2.0 2017-02-18 CRAN (R 3.4.0)
tools 3.4.3 2017-12-07 local
tufte 0.2.8 2018-01-11 Github (rstudio/tufte@2445598)
utils * 3.4.3 2017-12-07 local
yaml 2.1.16 2017-12-12 CRAN (R 3.4.3)
> rmarkdown::pandoc_version()
[1] ‘2.0.6’
Thanks.
When I run code:
title: "Tufte样式"
subtitle: "一个R Markdown实现"
author: "JJ Allaire,谢益辉"
date: "r Sys.Date()
"
output:
tufte::tufte_handout:
citation_package: natbib
latex_engine: xelatex
ctex: yes
biblio-title: 参考文献
bibliography: skeleton.bib
link-citations: yes
I can't get the pdf output,instead:
'Sorry, but D:\MikTEX\miktex\bin\xelatex.exe did not succeed.
The log file hopefully contains the information to get MiKTeX going again:
C:/Users/Jim/AppData/Local/MiKTeX/2.9/miktex/log/xelatex.log
You may want to visit the MiKTeX project page, if you need help.'
How can I get the pdf in Chinese?Thanks!
I am writing a document in RStudio / Rmarkdown / Tufte style. The document is in Turkish. I want to use Turkish translations for the words like "Figure, Table" and others.
Could you please help me?
Thanks for the terrific package—and for the whole knitrverse!
I wonder if there's a bug that affects links placed inside fig.cap when working with LaTeX (tufte_handout or tufte_book). Here's a MWE:
---
title: "Minimal Working Example"
output: tufte::tufte_handout # but tufte::tufte_html is fine
---
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse venenatis fringilla libero at tristique.
```{r fig.cap="A plot of the famous [cars data set](https://stat.ethz.ch/R-manual/R-devel/library/datasets/html/cars.html)."}
plot(cars)
```
Aliquam ut enim sodales, semper libero nec, bibendum velit. Pellentesque ultrices magna justo, in faucibus orci consequat sit amet.
This gives me the result:
Whereas substituting tufte::tufte_html
seems to work as expected.
Digging into the generated .tex
file, it looks like the problem is the link just hasn't been converted from markdown to LaTeX:
\begin{figure}
\includegraphics{MWE_files/figure-latex/unnamed-chunk-1-1} \caption[A plot of the famous [cars data set](https://stat.ethz.ch/R-manual/R-devel/library/datasets/html/cars.html)]{A plot of the famous [cars data set](https://stat.ethz.ch/R-manual/R-devel/library/datasets/html/cars.html).}\label{fig:unnamed-chunk-1}
\end{figure}
When the date is left blank in the RMarkdown file, it still appears in the compiled handout pdf. I fixed this problem by replacing
\date{$date$}
with this
\date{$date$}
\date{}
in tufte-handout.tex
First off, this is an excellent implementation of Tufte's elegant approach to page layout. Thank you.
I really like the idea of margin figures, however, they are often too small to read. A simple "click-to-zoom" functionality would be really handy. I suppose that this can be done with a little bit of CSS/JS magic.
I have found this post that could possible be adapted for use in a standard .Rmd vs. "ioslides_presentation". Tinkering around resulted in nothing useful.
Thanks.
@yihui This looks great!
I think the ebook class would fit right in.
I could just make the PR, but perhaps the easiest first step would be for you to take a look at it and see if there's anything you'd like me to modify first.
Regarding the comment from @jjallaire about minimal TeX distributions, I don't have any opinion. I included what files seemed to best conform with the way the other template packages were organized. I think there were a few changes to the original class files but not a huge number of them.
Since tufte html already looks very nice, in many cases it can immediately be used to created printed document. It would be handy if for these purposes there was a mechanism to set page size of the paper and also force manual page breaks in the document. Is there a way to do this?
If not, could such a mechanism be added?
At present the handout template doesn't support short running titles, as described in the first answer here: http://tex.stackexchange.com/questions/176082/modify-the-header-on-tufte-handout
Could the template be modified from:
\title{$title$}
to something like
\title[$runningheader$]{$title$}
Hi,
first of all let me thank you for the great package.
I have noticed that when in YAML I select some other highlighting of the code than the default (e.g. set to tango), the code blocks get shrunk. Is there any workaround for this behavior?
Best regards,
Michal
When I try to include two authors in the YAML header and build, I get the following error.
Is there a way to include multiple authors?
YAML
---
title: Title of submission
author:
- Author One
- Author Two
date: "`r format(Sys.time(), '%d %B %Y')`"
bibliography: mybibfile.bib
output:
tufte::tufte_handout: default
tufte::tufte_html: default
rticles::plos_article: default
csl: plos.csl
---
build command:
rmarkdown::render("Article.Rmd", tufte::tufte_handout(), output_dir="_out_tufte")
error:
! Extra \fi.
<argument> ...rrenvir \else \@badend {tabular}\fi
\expandafter \endgroup \if...
l.65 \author{Author One \and Author Two}
I love using the tufte_handout theme in RMarkdown. At times, I want to use the full width of the page for the main text. Is there a full-width text block feature similar to the full-width figure feature? If not, are there YAML or knitr options I could change to make the main text full width?
Hi @yihui,
just noticed the following: footnotes spreading across lines fail to be converted to sidenotes when the line wrapping is kept with pandoc option --wrap preserve
. This is because the regex in parse_footnotes
does not account for such scenario.
---
output:
tufte::tufte_html:
pandoc_args: ["--wrap", "preserve"]
---
Test ^[foot
note]
Hi guys,
I've been using R Markdown for a while for assignments in university. My experience has been terrific and I am forever grateful to @yihui and the rest of R Studio for creating and supporting it. Some assignments require the inclusion of code in the document, and I thought using Tufte style margins might be nice for including one liners and short snippets.
I was hoping there would be chunk option, similar to fig.margin but I don't think this feature is supported. I've been looking all over but I cannot find simple way to hack it either. There is no mention or example in the RStudio material, however I did see something in Michael Sachs original example. To place the code chunk in the margin he included the html aside tags which doesn't seem to work as he's specified any more, and alludes to using the pandoc footnote syntax for LaTeX/PDF. Pandoc footnotes seem to work for outputting inline R results, but I can't get it to work for code chunks.
Is there a way to achieve this and/or are there future plans to implement something like it? I don't know if this feature clashes with the Tufte style and understand that if this were so this might make this issue irrelevant.
I'm not 100% sure this is even an indented feature, but the rmarkdown docs seem to suggest it is possible to pass \usepackage{geometry}
options to a document, like so:
---
title: "Crop Analysis Q3 2013"
output: pdf_document
fontsize: 11pt
geometry: margin=1in
---
However, when using this option with the tufte::handout
template (the one right out of the RStudio 0.99.1281), the option appears not to work.
With this YAML, it's just ignored, and nothing changes:
---
title: "Tufte Handout"
author: "JJ Allaire and Yihui Xie"
date: '`r Sys.Date()`'
output:
tufte::tufte_handout:
citation_package: natbib
latex_engine: xelatex
tufte::tufte_book:
citation_package: natbib
latex_engine: xelatex
tufte::tufte_html: default
link-citations: yes
subtitle: An implementation in R Markdown
bibliography: skeleton.bib
geometry: margin=15in
---
With this YAML, it errors out:
---
title: "Tufte Handout"
author: "JJ Allaire and Yihui Xie"
date: '`r Sys.Date()`'
output:
tufte::tufte_handout:
citation_package: natbib
latex_engine: xelatex
geometry: margin=15in
tufte::tufte_book:
citation_package: natbib
latex_engine: xelatex
tufte::tufte_html: default
link-citations: yes
subtitle: An implementation in R Markdown
bibliography: skeleton.bib
---
It would be really nice to change the paper format and use other geometry options.
Am I using it wrong or is this a limitation/bug?
Hi!
Im sorry that im posting this as an issue, as I am pretty sure the fault is to be found on my end, since I am a total beginner. I couldn't find any better forum for my problem though.
The problem I have is with the html output, the pdf works fine. I get the following message when trying to knit your template as is:
Could not fetch http://hta-staff01.ht.lu.se/litt-rre$/Documents/R/win-library/3.4/tufte/rmarkdown/templates/tufte_html/resources/tufte-fonts.css HttpExceptionRequest Request { host = "hta-staff01.ht.lu.se" port = 80 secure = False requestHeaders = [] path = "/litt-rre$/Documents/R/win-library/3.4/tufte/rmarkdown/templates/tufte_html/resources/tufte-fonts.css" queryString = "" method = "GET" proxy = Nothing rawBody = False redirectCount = 10 responseTimeout = ResponseTimeoutDefault requestVersion = HTTP/1.
And then an additional message saying pandoc document conversion failed with error 61
etc. Ends with the statement Execution halted
.
Does this have something to do with the university computer I'm working and its network, firewalls perhaps? Or could it be something with the installation of R, pandoc or your tufte package?
Again, sorry if I hijack a forum were these kinds of newbie questions doesn't belong. I am a big fan of the looks and functionality of your package though and would very much like to be able to use it!
All the best
Robert
Even though I'm specifying fig.fullwidth = TRUE it doesn't seem to be respected and prints to main column as though the option isn't there. Gist to an example rmd is included here:
I don't know why (yet).
In playing around with the Tufte package on two windows machines, I was consistently getting "failure to compile errors:"
Failed to compile tufteonly.tex. See tufteonly.log for more info.
In addition: Warning message: running command ‘ “xelatex” -halt-onerror
-interaction=batchmode “tufteonly.tex” ’ had status 1 Execution
halted
It turns out that these were attributable to my use of headers with three pound signs, i.e., blank lines beginning w/ ### getting rid of these fixed it.
You should be able to replicate this if you rename the attached .txt as .Rmd and run.
tufteXelatexError3PoundSigns.txt
Beautiful package.
Is there a way to produce a full-width table?
According to the tufte_book LaTeX documentation, this would be implemented with a table*
environment rather than table
(page 23). I see how to do the full-width figure (fig.fullwidth = TRUE
), but cannot see the table equivalent.
This is simply a feature request. It would be nice to have a Tufte styled navigation bar as an option rather than requiring the user to manually create this. I might have a go at a fork.
Thanks for this package. Looks fantastic.
I've encountered a problem with percent signs in the margin_note() function. It works fine when I knit as html, but it's causing pandoc to choke when I knit as pdf. I assume it's being passed to pandoc unescaped, but if I use %, then R chokes on it. Any suggestions?
There is a very nice sans-serif adaptation of this tufte template in the tint
package by @eddelbuettel. I wonder if that template could be added to this package?
It would be great to have an easy sans-serif tufte template for bookdown, too. Perhaps tint would be suitable for that? The current tufte html output for bookdown is the least pleasant of all the bookdown output options (on my screen at least), with the yellow background and big black navigation buttons at the top).
I am trying to change the rendering engine to xelatex because I have some unicode characters in my Rmarkdown file that pdflatex throws an error on
/usr/bin/pandoc +RTS -K512m -RTS Protocol.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output /projects/PROTOCOL/Description/_out_tufte_pdf/Protocol.pdf --table-of-contents --toc-depth 2 --template /usr/local/lib/R/site-library/tufte/rmarkdown/templates/tufte_handout/resources/tufte-handout.tex --hi
ghlight-style pygments --latex-engine pdflatex --variable 'documentclass:tufte-handout' --bibliography mybibfile.bib --filter /usr/bin/pandoc-citeproc
! Package inputenc Error: Unicode char μ (U+3BC)
(inputenc) not set up for use with LaTeX.
See the inputenc package documentation for explanation.
Type H <return> for immediate help.
...
l.343 ...cy, corresponding to the rate of rise (μ
Try running pandoc with --latex-engine=xelatex.
pandoc: Error producing PDF
Error: pandoc document conversion failed with error 43
Execution halted
I have tried a few different methods but the --latex-engine pdflatex
keeps being selected.
My YAML header is the following:
---
title: Protocol
author:
- FRM
date: "`r format(Sys.time(), '%d %B %Y')`"
bibliography: mybibfile.bib
link-citations: yes
header-includes:
- \usepackage{fontenc}
output:
tufte::tufte_handout:
fig_width: 6
fig_height: 4.5
keep_tex: true
latex_engine: xelatex
toc: true
pandoc_args: [
"--latex-engine=xelatex"
]
includes:
# in_header: preamble.tex
# before_body: doc_prefix.tex
# after_body: doc_suffix.tex
tufte::tufte_html: default
rticles::plos_article: default
word_document:
fig_width: 5
fig_height: 5
fig_caption: true
csl: plos.csl
abstract: "(Abstract: to be expanded)"
---
as you see, I've also tried passing pandoc arguments
The build file looks like this (I'm building in HTML/word/PDF in the same build)
#!/usr/bin/Rscript
# this script builds our article.
require(knitr)
require(rmarkdown)
require(rticles)
require(tufte)
setwd("~/PROTOCOL/Description/")
# build in article format: plos
# nb: marginnotes don't work in this format!
# rmarkdown::render("Article.Rmd", rticles::plos_article(), output_dir="_out_pdf")
# build word format
rmarkdown::render("Protocol.Rmd", output_format = "word_document", output_dir="_out_word")
# see
# http://rmarkdown.rstudio.com/articles_docx.html
# build in tufte format
# NB: multiple authors are not supported in this format
# see
# - http://rmarkdown.rstudio.com/tufte_handout_format.html
# - http://rstudio.github.io/tufte/
rmarkdown::render("Protocol.Rmd", tufte::tufte_handout(toc = TRUE), output_dir="_out_tufte_pdf")
rmarkdown::render("Protocol.Rmd", tufte::tufte_html(), output_dir="_out_tufte_html")
Am I missing some way to force building with xelatex?
Hi, I have an Rmd document with the following front matter. Using output: tufte_html
fails to output any citation at the end of the document. The same yaml works using output: html_document()
or with link-citations: no
.
---
title: "Business-oriented Typology and Characterization of Agriculture in SSA"
subtitle: A multi-scale and cross-time framework
author: '[Melanie Bacou](http://github.com/mbacou)'
date: "Last updated on `r Sys.Date()`. DRAFT, DO NOT USE OR CITE."
output:
tufte::tufte_html:
tufte_variant: envisioned
toc: yes
toc_depth: 2
df_print: paged
fig_caption: yes
fig_height: 5
bibliography: biblio.bib
csl: apa.csl
link-citations: yes
nocite: |
@aasr_2016, @alvarez2014typology, @jayne2015agdev, @hazell2013urban, @douillet2014developing, @jordan2005eth, @omamo2006strategic, @bacou2015ethseg, @omamo2006strategic, @benin2016agricultural, @willy2015adaptation, @jayne2015africafarmland, @diao2017ghana
---
Thanks for the great package. I am using it to write a bookdown book with HTML and PDF output.
My problem is that I am trying to center a margin figure instead of accepting the defaul of left-align. PDF output works fine, but HTML output does not handle the below snippet properly:
{r nice-fig, fig.cap='Here is a nice figure!', fig.asp=.75,
fig.margin = TRUE, out.width = "30%", fig.align = "center"}
par(mar = c(4, 4, .1, .1))
plot(pressure, type = 'b', pch = 19)
Output puts figure in center of main text instead of centering in margin:
Only hide side notes and margin notes.
I just started writing some Work using Rmarkdown.
Somehow on my maschine the placements of "Footnotes" on the side does not work.
Installed all packages. Just tried the example.
However this is a reduced example.
Of course I replace ´ with `
---
title: "Test"
subtitle: "More Test"
author: "Someone"
date: "`r Sys.Date()`"
output:
tufte::tufte_html: default
link-citations: yes
---
´´´
{r setup, include=FALSE}
library(tufte)
# invalidate cache when the tufte version changes
knitr::opts_chunk$set(tidy = FALSE, cache.extra = packageVersion('tufte'))
options(htmltools.dir.version = FALSE)
´´´
# Introduction
This style has been implemented in LaTeX and HTML/CSS^[See Github repositories [tufte-latex](https://github.com/tufte-latex/tufte-latex) and [tufte-css](https://github.com/edwardtufte/tufte-css)], respectively.
RStudio Edition : Desktop
RStudio Version : 1.1.442
OS Version : Windows 7 Professional
R Version : 3.4.4
rmarkdown : 1.9
knitr : 1.20
tufte : 0.3
pandoc : 2.1.3
Knit to tufte_book
the following tufte default template, as a pdf. It won't knit and instead I get an "Error: pandoc document conversion failed with error 5". I have reinstalled R Studio, updated to R 3.4.4 and updated all my packages with update.packages()
.
I am able to knit the default tufte_template to HTML without issue. When I do the tufte_book to pdf is when I get that error.
[Edit] Updated to the dev version of tufte and cleaned up my code. Now I get the error Error in tools::file_path_as_absolute(output_file) : file 'tufte_book.pdf' does not exist.
---
title: "Tufte Handout"
subtitle: "An implementation in R Markdown"
author: "JJ Allaire and Yihui Xie"
date: "`r Sys.Date()`"
output:
tufte::tufte_book:
citation_package: natbib
latex_engine: xelatex
tufte::tufte_handout:
citation_package: natbib
latex_engine: xelatex
tufte::tufte_html: default
bibliography: skeleton.bib
link-citations: yes
---
```{r setup, include=FALSE}
library(tufte)
# invalidate cache when the tufte version changes
knitr::opts_chunk$set(tidy = FALSE, cache.extra = packageVersion('tufte'))
options(htmltools.dir.version = FALSE)
```
# Introduction
The Tufte handout style is a style that Edward Tufte uses in his books and handouts. Tufte's style is known for its extensive use of sidenotes, tight integration of graphics with text, and well-set typography. This style has been implemented in LaTeX and HTML/CSS^[See Github repositories [tufte-latex](https://github.com/tufte-latex/tufte-latex) and [tufte-css](https://github.com/edwardtufte/tufte-css)], respectively. We have ported both implementations into the [**tufte** package](https://github.com/rstudio/tufte). If you want LaTeX/PDF output, you may use the `tufte_handout` format for handouts, and `tufte_book` for books. For HTML output, use `tufte_html`. These formats can be either specified in the YAML metadata at the beginning of an R Markdown document (see an example below), or passed to the `rmarkdown::render()` function. See @R-rmarkdown more information about **rmarkdown**.
```yaml
---
title: "An Example Using the Tufte Style"
author: "John Smith"
output:
tufte::tufte_handout: default
tufte::tufte_html: default
---
```
There are two goals of this package:
1. To produce both PDF and HTML output with similar styles from the same R Markdown document;
1. To provide simple syntax to write elements of the Tufte style such as side notes and margin figures, e.g. when you want a margin figure, all you need to do is the chunk option `fig.margin = TRUE`, and we will take care of the details for you, so you never need to think about `\begin{marginfigure} \end{marginfigure}` or `<span class="marginfigure"> </span>`; the LaTeX and HTML code under the hood may be complicated, but you never need to learn or write such code.
If you have any feature requests or find bugs in **tufte**, please do not hesitate to file them to https://github.com/rstudio/tufte/issues. For general questions, you may ask them on StackOverflow: http://stackoverflow.com/tags/rmarkdown.
I have a pretty simple Rmd that generates a bunch of figures, each in its own section. The figures are not showing up inside the correct sections starting with the 5th section and the subtitle doesn't appear at all in the document. I am knitting the document by pressing the knit button in RStudio. Here is a simple example that reproduces the issues:
--- title: "This is The Title" subtitle: "Subtitle" author: "JKGrain" date: "`r Sys.Date()`" output: tufte::tufte_handout: default --- ```{r setup, include=FALSE} library(tufte) # invalidate cache when the tufte version changes knitr::opts_chunk$set(cache.extra = packageVersion('tufte'), echo=FALSE) options(htmltools.dir.version = FALSE) # load required libaries library(ggplot2) p1 <- ggplot(mpg) + geom_point(aes(x=displ, y=hwy, color=cyl)) ``` # Section 1 ```{r sec1, fig.cap = "The first caption"} p1 ``` # Section 2 ```{r sec2, fig.cap = "The second caption"} p1 ``` # Section 3 ```{r sec3, fig.cap = "The third caption"} p1 ``` # Section 4 ```{r sec4, fig.cap = "The fourth caption"} p1 ``` # Section 5 ```{r sec5, fig.cap = "The fifth caption"} p1 ``` # Section 6 ```{r sec6, fig.cap = "The sixth caption"} p1 ``` # Section 7 ```{r sec7, fig.cap = "The seventh caption"} p1 ``` # Section 8 ```{r sec8, fig.cap = "The eighth caption"} p1 ```
when I change the YAML to:
tufte::tufte_html: default
and press the knit button in Rstudio, the html renders correctly with the figures all in the correct sections and the subtitle. The PDF output is pretty useless though at this point. I have to email the report and I can't use the html version.
Thanks for looking at this.
Looks like it's not possible to use subsubsections, like
## Subsection
### Subsubsection
This would be good to handle without an error as it will pretty commonly be used
I am currently running a mashup of jekyll/rmarkdown/tufte/servr to render my research blog, and it employs several workarounds. I'm hoping that by outlining such workarounds, it'll start a dialogue on how best to support such a system. And perhaps people who are trying something similar will find this useful.
Based on your build.R from knitr-jekyll, I have a similar version, the biggest difference being that instead of running knitr::knit
, I run rmarkdown::render
, so that I can take advantage of the tufte
html styles.
This then introduces a host of problems:
tufte/R/html.R
in the tufte
package to manually reinstate the frontmatter. Originally, I thought I could just pass a post_processor to do that work, but it turns out that html_documents already have a post_processor, and since there's no chaining, the post-processor I pass in will just be replaced.build.R
file.servr::jekyll
– _source to _post for instance – that calls for some manual renaming when combined with rmarkdown
. Also tufte_html
outputs a html file, which we then need to rename into .md
(my custom template.html
is basically $body$
). All this can be found in my build.R
. One solution here would be to have something like a tufte_md
class perhaps?Right now, this setup works for me, but it's obviously a series of temporary hacks that will one day fail.
Adding the yaml header number_sections
works in html mode, for pdf handout it does not work.
The numbered sections appear in the toc though (if that option is set).
The command-line call to pandoc shows it, though, so it may well be the latex class not supporting it. In that case ... should the top-level argument be ignored / trigger a warning in tufte_handout()
? The disconnect between table of contents and actual sections is a little weird.
According to the documentation non-simple marginnotes should be set as a marginfigure
chunk since markdown will parse the chunk content correctly. Thus if I have a piece of code that - in "default Tufte" - would read something like this
yada yada yada yada. `r margin_note("For example root mean squared error $\sqrt{\frac1n \sum_{i=1}^n (\hat y_i - y_i)^2}$")` yada yada yada yada
then I replace it with
yada yada yada yada.
```{marginfigure}
For example root mean squared error $\sqrt{\frac1n \sum_{i=1}^n (\hat y_i - y_i)^2}$
```
yada yada yada yada
However, a new paragraph is inadvertently introduced when the marginfigure
chunk is used in the middle of the paragraph. I would like the text to run continunously
yada yada yada yada yada yada yada yada
with the math in the right-hand column. Is that at all possible? Or can I allow pandoc to parse the content of margin_note()
?
The example on http://rmarkdown.rstudio.com/tufte_handout_format.html fails because of missing template file(s):
> draft("my_handout.Rmd", template = "tufte_handout", package = "tufte")
Error in draft("my_handout.Rmd", template = "tufte_handout", package = "tufte") :
No template.yaml file found for template 'tufte_handout'
Getting:
Error in html_document_base(smart = smart, theme = theme, self_contained = self_contained, :
formal argument "extra_dependencies" matched by multiple actual arguments
Calls: ... html_document2 -> -> output_format -> html_document_base
Execution halted
when trying to use tufte::tufte_html: default
. It broke on a larger document but it also broke on this smaller snippet:
---
title: "Tufte Handout"
subtitle: "An implementation in R Markdown"
author: "JJ Allaire and Yihui Xie"
date: "`r Sys.Date()`"
output:
tufte::tufte_html: default
---
```{r setup, include=FALSE}
library(tufte)
knitr::opts_chunk$set(tidy = FALSE, cache.extra = packageVersion('tufte'))
options(htmltools.dir.version = FALSE)
```
test
I even tried the github versions of rmarkdown
and tufte
.
Session info -----------------------------------------------------------------
setting value
version R version 3.2.3 (2015-12-10)
system x86_64, darwin13.4.0
ui RStudio (0.99.862)
language (EN)
collate en_US.UTF-8
tz America/New_York
date 2016-01-24
Packages ---------------------------------------------------------------------
package * version date source
devtools * 1.9.1 2015-09-11 CRAN (R 3.2.0)
digest 0.6.9 2016-01-08 CRAN (R 3.2.3)
htmltools 0.3 2015-12-29 CRAN (R 3.2.3)
knitr * 1.12.3 2016-01-22 CRAN (R 3.2.3)
memoise 0.2.1 2014-04-22 CRAN (R 3.2.0)
rmarkdown * 0.9.5 2016-01-25 Github (rstudio/rmarkdown@fda019a)
rsconnect 0.4.1.11 2016-01-06 Github (rstudio/rsconnect@3034ab8)
tufte * 0.1.1 2016-01-25 Github (rstudio/tufte@7ad0b6b)
yaml 2.1.13 2014-06-12 CRAN (R 3.2.0)
I'm probably doing something wrong/broke something, but I'm not sure what.
It always takes the book title and author as running head. But in tufte-latex example package from CTAN, the running head contains chapter title, which is what should be.
I recently installed tufte and rmarkdown with devtools (I'm not using Rstudio).
I created an example using draft("notes.Rmd", template = "tufte_html", package = "tufte")
The html works perfect, I wanted to create a pdf, and I modified the header to this:
---
title: "Tufte Handout"
subtitle: "An implementation in R Markdown"
author: "JJ Allaire and Yihui Xie"
date: "`r Sys.Date()`"
output:
tufte::tufte_handout:
citation_package: natbib
latex_engine: xelatex
keep_tex: true
tufte::tufte_html: default
tufte::tufte_book:
citation_package: natbib
latex_engine: xelatex
bibliography: skeleton.bib
link-citations: yes
---
But the pdf has the image with the caption "MPG vs horsepower, colored by transmission]{MPG vs horse-power, colored by transmission" pretty messed up: it doesn't appear in the margin, and the pdf prints part of the latex code. I peaked at the latex code and I found stuff like this:
\textbackslash{}begin\{marginfigure\}
\includegraphics{ADA_notes_files/figure-latex/fig-margin-1}
\textbackslash{}caption{[}MPG vs horsepower, colored by
transmission{]}\{MPG vs horsepower, colored by
transmission.\}\label{fig:fig-margin}
\textbackslash{}end\{marginfigure\}
I'm also attaching the tex file here as txt: notes.txt
Is there some workaround? Or it could be because of a problem between the versions?
my sessionInfo() looks like this:
R version 3.2.3 (2015-12-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 15.04
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=de_DE.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=de_DE.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=de_DE.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] knitr_1.14 slidify_0.4.5 rmarkdown_1.0.9016 tufte_0.2.2
loaded via a namespace (and not attached):
[1] Rcpp_0.12.7 digest_0.6.8 withr_1.0.2 assertthat_0.1
[5] R6_2.1.1 git2r_0.11.0 magrittr_1.5 evaluate_0.9
[9] httr_1.0.0 stringi_1.1.1 curl_0.9.3 whisker_0.3-2
[13] devtools_1.12.0 tools_3.2.3 stringr_1.1.0 markdown_0.7.7
[17] yaml_2.1.13 memoise_1.0.0 htmltools_0.3.5 tibble_1.2
>
(Unrelated to all this, you guys are doing pretty cool stuff! Every single time I start to use something new, I discover that the author is either Yihui Xie or Hadley Wickham)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.