{"action":"created","comment":{"url":"https://api.github.com/repos/rstudio/rmarkdown/pulls/comments/48542408","id":48542408,"diff_hunk":"@@ -56,26 +46,50 @@ tufte_handout <- function(fig_width = 4,\n   \n   # set hooks for special plot output\n   knitr_options$knit_hooks$plot <- function(x, options) {\n-    \n-    # determine caption (if any)\n-    caption <- ifelse(is.null(options$fig.cap), \n-                      \"\",\n-                      paste(\"\\\\caption{\", options$fig.cap, \"}\\n\", sep = \"\"))\n-    \n+\n     # determine figure type\n     if (isTRUE(options$fig.margin)) \n-      figtype <- \"marginfigure\"\n+      options$fig.env <- \"marginfigure\"\n     else if (isTRUE(options$fig.fullwidth))\n-      figtype <- \"figure*\"\n-    else\n-      figtype <- \"figure\"\n-    \n-    # return the latex\n-    paste(sprintf('\\\\begin{%s}\\n \\\\includegraphics{%s}\\n%s\\\\end{%s}\\n',\n-                  figtype, x, caption, figtype))\n+      options$fig.env <- \"figure*\"\n+\n+    knitr::hook_plot_tex(x, options)\n   }\n   \n   # override the knitr settings of the base format and return the format\n   format$knitr <- knitr_options\n   format\n }\n+\n+#' @details \\code{tufte_html()} provides the HTML format based on the Tufte CSS:\n+#'   \\url{https://edwardtufte.github.io/tufte-css/}.\n+#' @param css One or more CSS files to include, and the Tufte CSS will always be\n+#'   included in this list\n+#' @rdname tufte_handout\n+#' @export\n+tufte_html <- function(css = NULL, ...) {\n+  tufte_css <- rmarkdown_system_file(\n+    'rmarkdown', 'templates', 'tufte_html', 'resources', 'tufte.css'\n+  )\n+  css <- c(tufte_css, css)\n+  html_document(css = css, theme = NULL, ...)\n+}\n+\n+#' @details \\code{newthought()} can be used in inline R expressions in R\n+#'   Markdown (e.g. \\samp{`r newthought(Some text)`}), and it works for both\n+#'   HTML (\\samp{<span class=\"newthought\">text</span>}) and PDF\n+#'   (\\samp{\\\\newthought{text}}) output.\n+#' @param text A character string to be presented as a \\dQuote{new thought}\n+#'   (using small caps)\n+#' @rdname tufte_handout\n+#' @export\n+newthought <- function(text) {\n+  if (is_html_output()) {\n+    sprintf('<span class=\"newthought\">%s</span>', text)\n+  } else if (is_latex_output()) {\n+    sprintf('\\\\newthought{%s}', text)\n+  } else {\n+    warning('newthought() only works for HTML and LaTeX output')","path":"R/tufte_handout.R","position":131,"original_position":131,"commit_id":"429814d69fd2d3b38f0e662bbf5c5f8e784b8119","original_commit_id":"429814d69fd2d3b38f0e662bbf5c5f8e784b8119","user":{"login":"hadley","id":4196,"avatar_url":"https://avatars.githubusercontent.com/u/4196?v=3","gravatar_id":"","url":"https://api.github.com/users/hadley","html_url":"https://github.com/hadley","followers_url":"https://api.github.com/users/hadley/followers","following_url":"https://api.github.com/users/hadley/following{/other_user}","gists_url":"https://api.github.com/users/hadley/gists{/gist_id}","starred_url":"https://api.github.com/users/hadley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hadley/subscriptions","organizations_url":"https://api.github.com/users/hadley/orgs","repos_url":"https://api.github.com/users/hadley/repos","events_url":"https://api.github.com/users/hadley/events{/privacy}","received_events_url":"https://api.github.com/users/hadley/received_events","type":"User","site_admin":false},"body":"I think it's good practice to do `call. = FALSE` in `warning()`, but I'm not sure what the RStudio style is.","created_at":"2015-12-29T14:13:17Z","updated_at":"2015-12-29T14:13:17Z","html_url":"https://github.com/rstudio/rmarkdown/pull/581#discussion_r48542408","pull_request_url":"https://api.github.com/repos/rstudio/rmarkdown/pulls/581","_links":{"self":{"href":"https://api.github.com/repos/rstudio/rmarkdown/pulls/comments/48542408"},"html":{"href":"https://github.com/rstudio/rmarkdown/pull/581#discussion_r48542408"},"pull_request":{"href":"https://api.github.com/repos/rstudio/rmarkdown/pulls/581"}}},"pull_request":{"url":"https://api.github.com/repos/rstudio/rmarkdown/pulls/581","id":54670009,"html_url":"https://github.com/rstudio/rmarkdown/pull/581","diff_url":"https://github.com/rstudio/rmarkdown/pull/581.diff","patch_url":"https://github.com/rstudio/rmarkdown/pull/581.patch","issue_url":"https://api.github.com/repos/rstudio/rmarkdown/issues/581","number":581,"state":"open","locked":false,"title":"Tufte CSS","user":{"login":"yihui","id":163582,"avatar_url":"https://avatars.githubusercontent.com/u/163582?v=3","gravatar_id":"","url":"https://api.github.com/users/yihui","html_url":"https://github.com/yihui","followers_url":"https://api.github.com/users/yihui/followers","following_url":"https://api.github.com/users/yihui/following{/other_user}","gists_url":"https://api.github.com/users/yihui/gists{/gist_id}","starred_url":"https://api.github.com/users/yihui/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yihui/subscriptions","organizations_url":"https://api.github.com/users/yihui/orgs","repos_url":"https://api.github.com/users/yihui/repos","events_url":"https://api.github.com/users/yihui/events{/privacy}","received_events_url":"https://api.github.com/users/yihui/received_events","type":"User","site_admin":false},"body":"This PR is for porting https://edwardtufte.github.io/tufte-css/ into rmarkdown. **It is not ready to be merged yet.** There are still quite a few things to be tweaked in the CSS before it works well with Pandoc.\r\n\r\n@jjallaire Since tufte.css has some fonts dependencies, the `tufte_html()` format won't work well when `self_contained = FALSE`. Could you tell me how to declare these dependencies in the format function `tufte_html()`? Ideally, `render()` should copy tufte.css and the fonts (the `et-book` directory) to the output directory when render HTML output that is not self-contained. Thanks!","created_at":"2015-12-28T17:21:05Z","updated_at":"2015-12-29T14:13:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fcc1755a46cf7d125cf167e857641e1e8993d0a7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rstudio/rmarkdown/pulls/581/commits","review_comments_url":"https://api.github.com/repos/rstudio/rmarkdown/pulls/581/comments","review_comment_url":"https://api.github.com/repos/rstudio/rmarkdown/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rstudio/rmarkdown/issues/581/comments","statuses_url":"https://api.github.com/repos/rstudio/rmarkdown/statuses/429814d69fd2d3b38f0e662bbf5c5f8e784b8119","head":{"label":"yihui:feature/tufte-html","ref":"feature/tufte-html","sha":"429814d69fd2d3b38f0e662bbf5c5f8e784b8119","user":{"login":"yihui","id":163582,"avatar_url":"https://avatars.githubusercontent.com/u/163582?v=3","gravatar_id":"","url":"https://api.github.com/users/yihui","html_url":"https://github.com/yihui","followers_url":"https://api.github.com/users/yihui/followers","following_url":"https://api.github.com/users/yihui/following{/other_user}","gists_url":"https://api.github.com/users/yihui/gists{/gist_id}","starred_url":"https://api.github.com/users/yihui/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yihui/subscriptions","organizations_url":"https://api.github.com/users/yihui/orgs","repos_url":"https://api.github.com/users/yihui/repos","events_url":"https://api.github.com/users/yihui/events{/privacy}","received_events_url":"https://api.github.com/users/yihui/received_events","type":"User","site_admin":false},"repo":{"id":23904200,"name":"rmarkdown","full_name":"yihui/rmarkdown","owner":{"login":"yihui","id":163582,"avatar_url":"https://avatars.githubusercontent.com/u/163582?v=3","gravatar_id":"","url":"https://api.github.com/users/yihui","html_url":"https://github.com/yihui","followers_url":"https://api.github.com/users/yihui/followers","following_url":"https://api.github.com/users/yihui/following{/other_user}","gists_url":"https://api.github.com/users/yihui/gists{/gist_id}","starred_url":"https://api.github.com/users/yihui/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yihui/subscriptions","organizations_url":"https://api.github.com/users/yihui/orgs","repos_url":"https://api.github.com/users/yihui/repos","events_url":"https://api.github.com/users/yihui/events{/privacy}","received_events_url":"https://api.github.com/users/yihui/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yihui/rmarkdown","description":"Dynamic Documents for R","fork":true,"url":"https://api.github.com/repos/yihui/rmarkdown","forks_url":"https://api.github.com/repos/yihui/rmarkdown/forks","keys_url":"https://api.github.com/repos/yihui/rmarkdown/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yihui/rmarkdown/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yihui/rmarkdown/teams","hooks_url":"https://api.github.com/repos/yihui/rmarkdown/hooks","issue_events_url":"https://api.github.com/repos/yihui/rmarkdown/issues/events{/number}","events_url":"https://api.github.com/repos/yihui/rmarkdown/events","assignees_url":"https://api.github.com/repos/yihui/rmarkdown/assignees{/user}","branches_url":"https://api.github.com/repos/yihui/rmarkdown/branches{/branch}","tags_url":"https://api.github.com/repos/yihui/rmarkdown/tags","blobs_url":"https://api.github.com/repos/yihui/rmarkdown/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yihui/rmarkdown/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yihui/rmarkdown/git/refs{/sha}","trees_url":"https://api.github.com/repos/yihui/rmarkdown/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yihui/rmarkdown/statuses/{sha}","languages_url":"https://api.github.com/repos/yihui/rmarkdown/languages","stargazers_url":"https://api.github.com/repos/yihui/rmarkdown/stargazers","contributors_url":"https://api.github.com/repos/yihui/rmarkdown/contributors","subscribers_url":"https://api.github.com/repos/yihui/rmarkdown/subscribers","subscription_url":"https://api.github.com/repos/yihui/rmarkdown/subscription","commits_url":"https://api.github.com/repos/yihui/rmarkdown/commits{/sha}","git_commits_url":"https://api.github.com/repos/yihui/rmarkdown/git/commits{/sha}","comments_url":"https://api.github.com/repos/yihui/rmarkdown/comments{/number}","issue_comment_url":"https://api.github.com/repos/yihui/rmarkdown/issues/comments{/number}","contents_url":"https://api.github.com/repos/yihui/rmarkdown/contents/{+path}","compare_url":"https://api.github.com/repos/yihui/rmarkdown/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yihui/rmarkdown/merges","archive_url":"https://api.github.com/repos/yihui/rmarkdown/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yihui/rmarkdown/downloads","issues_url":"https://api.github.com/repos/yihui/rmarkdown/issues{/number}","pulls_url":"https://api.github.com/repos/yihui/rmarkdown/pulls{/number}","milestones_url":"https://api.github.com/repos/yihui/rmarkdown/milestones{/number}","notifications_url":"https://api.github.com/repos/yihui/rmarkdown/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yihui/rmarkdown/labels{/name}","releases_url":"https://api.github.com/repos/yihui/rmarkdown/releases{/id}","created_at":"2014-09-11T04:33:03Z","updated_at":"2015-12-28T19:59:41Z","pushed_at":"2015-12-28T22:58:31Z","git_url":"git://github.com/yihui/rmarkdown.git","ssh_url":"git@github.com:yihui/rmarkdown.git","clone_url":"https://github.com/yihui/rmarkdown.git","svn_url":"https://github.com/yihui/rmarkdown","homepage":"http://rmarkdown.rstudio.com/","size":10144,"stargazers_count":2,"watchers_count":2,"language":"R","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2,"mirror_url":null,"open_issues_count":0,"forks":2,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"rstudio:master","ref":"master","sha":"083d8ca5185321875769dafc4738ca6c9f82b591","user":{"login":"rstudio","id":513560,"avatar_url":"https://avatars.githubusercontent.com/u/513560?v=3","gravatar_id":"","url":"https://api.github.com/users/rstudio","html_url":"https://github.com/rstudio","followers_url":"https://api.github.com/users/rstudio/followers","following_url":"https://api.github.com/users/rstudio/following{/other_user}","gists_url":"https://api.github.com/users/rstudio/gists{/gist_id}","starred_url":"https://api.github.com/users/rstudio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rstudio/subscriptions","organizations_url":"https://api.github.com/users/rstudio/orgs","repos_url":"https://api.github.com/users/rstudio/repos","events_url":"https://api.github.com/users/rstudio/events{/privacy}","received_events_url":"https://api.github.com/users/rstudio/received_events","type":"Organization","site_admin":false},"repo":{"id":16146440,"name":"rmarkdown","full_name":"rstudio/rmarkdown","owner":{"login":"rstudio","id":513560,"avatar_url":"https://avatars.githubusercontent.com/u/513560?v=3","gravatar_id":"","url":"https://api.github.com/users/rstudio","html_url":"https://github.com/rstudio","followers_url":"https://api.github.com/users/rstudio/followers","following_url":"https://api.github.com/users/rstudio/following{/other_user}","gists_url":"https://api.github.com/users/rstudio/gists{/gist_id}","starred_url":"https://api.github.com/users/rstudio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rstudio/subscriptions","organizations_url":"https://api.github.com/users/rstudio/orgs","repos_url":"https://api.github.com/users/rstudio/repos","events_url":"https://api.github.com/users/rstudio/events{/privacy}","received_events_url":"https://api.github.com/users/rstudio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rstudio/rmarkdown","description":"Dynamic Documents for R","fork":false,"url":"https://api.github.com/repos/rstudio/rmarkdown","forks_url":"https://api.github.com/repos/rstudio/rmarkdown/forks","keys_url":"https://api.github.com/repos/rstudio/rmarkdown/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rstudio/rmarkdown/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rstudio/rmarkdown/teams","hooks_url":"https://api.github.com/repos/rstudio/rmarkdown/hooks","issue_events_url":"https://api.github.com/repos/rstudio/rmarkdown/issues/events{/number}","events_url":"https://api.github.com/repos/rstudio/rmarkdown/events","assignees_url":"https://api.github.com/repos/rstudio/rmarkdown/assignees{/user}","branches_url":"https://api.github.com/repos/rstudio/rmarkdown/branches{/branch}","tags_url":"https://api.github.com/repos/rstudio/rmarkdown/tags","blobs_url":"https://api.github.com/repos/rstudio/rmarkdown/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rstudio/rmarkdown/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rstudio/rmarkdown/git/refs{/sha}","trees_url":"https://api.github.com/repos/rstudio/rmarkdown/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rstudio/rmarkdown/statuses/{sha}","languages_url":"https://api.github.com/repos/rstudio/rmarkdown/languages","stargazers_url":"https://api.github.com/repos/rstudio/rmarkdown/stargazers","contributors_url":"https://api.github.com/repos/rstudio/rmarkdown/contributors","subscribers_url":"https://api.github.com/repos/rstudio/rmarkdown/subscribers","subscription_url":"https://api.github.com/repos/rstudio/rmarkdown/subscription","commits_url":"https://api.github.com/repos/rstudio/rmarkdown/commits{/sha}","git_commits_url":"https://api.github.com/repos/rstudio/rmarkdown/git/commits{/sha}","comments_url":"https://api.github.com/repos/rstudio/rmarkdown/comments{/number}","issue_comment_url":"https://api.github.com/repos/rstudio/rmarkdown/issues/comments{/number}","contents_url":"https://api.github.com/repos/rstudio/rmarkdown/contents/{+path}","compare_url":"https://api.github.com/repos/rstudio/rmarkdown/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rstudio/rmarkdown/merges","archive_url":"https://api.github.com/repos/rstudio/rmarkdown/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rstudio/rmarkdown/downloads","issues_url":"https://api.github.com/repos/rstudio/rmarkdown/issues{/number}","pulls_url":"https://api.github.com/repos/rstudio/rmarkdown/pulls{/number}","milestones_url":"https://api.github.com/repos/rstudio/rmarkdown/milestones{/number}","notifications_url":"https://api.github.com/repos/rstudio/rmarkdown/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rstudio/rmarkdown/labels{/name}","releases_url":"https://api.github.com/repos/rstudio/rmarkdown/releases{/id}","created_at":"2014-01-22T17:25:19Z","updated_at":"2015-12-27T14:09:29Z","pushed_at":"2015-12-28T22:58:32Z","git_url":"git://github.com/rstudio/rmarkdown.git","ssh_url":"git@github.com:rstudio/rmarkdown.git","clone_url":"https://github.com/rstudio/rmarkdown.git","svn_url":"https://github.com/rstudio/rmarkdown","homepage":"http://rmarkdown.rstudio.com/","size":41550,"stargazers_count":423,"watchers_count":423,"language":"R","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":230,"mirror_url":null,"open_issues_count":120,"forks":230,"open_issues":120,"watchers":423,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rstudio/rmarkdown/pulls/581"},"html":{"href":"https://github.com/rstudio/rmarkdown/pull/581"},"issue":{"href":"https://api.github.com/repos/rstudio/rmarkdown/issues/581"},"comments":{"href":"https://api.github.com/repos/rstudio/rmarkdown/issues/581/comments"},"review_comments":{"href":"https://api.github.com/repos/rstudio/rmarkdown/pulls/581/comments"},"review_comment":{"href":"https://api.github.com/repos/rstudio/rmarkdown/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rstudio/rmarkdown/pulls/581/commits"},"statuses":{"href":"https://api.github.com/repos/rstudio/rmarkdown/statuses/429814d69fd2d3b38f0e662bbf5c5f8e784b8119"}}}}