Skip to content

Commit

Permalink
final fix for #65: dynamically set the page size for printing
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui committed Aug 9, 2017
1 parent 77c258c commit 3e4eee0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions R/render.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ moon_reader = function(
tags$script(HTML(paste(c(sprintf(
'var slideshow = remark.create(%s);', if (length(nature)) knitr:::tojson(nature) else ''
), "if (window.HTMLWidgets) slideshow.on('afterShowSlide', function (slide) {window.dispatchEvent(new Event('resize'));});",
'(function() {var d = document, s = d.createElement("style"), r = d.querySelector(".remark-slide-scaler"); if (!r) return; s.type = "text/css"; s.innerHTML = "@page {size: " + r.style.width + " " + r.style.height +"; }"; d.head.appendChild(s);})();',
play_js, countdown_js), collapse = '\n')))
)), tmp_js)

Expand Down
1 change: 1 addition & 0 deletions inst/rmarkdown/templates/xaringan/resources/example.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ table thead th { border-bottom: 1px solid #ddd; }
th, td { padding: 5px; }
thead, tfoot, tr:nth-child(even) { background: #eee }

@page { margin: 0; }
@media print {
.remark-slide-scaler {
width: 100% !important;
Expand Down
1 change: 1 addition & 0 deletions inst/rmarkdown/templates/xaringan_zh-CN/skeleton/zh-CN.css
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ table thead th { border-bottom: 1px solid #ddd; }
th, td { padding: 5px; }
thead, tfoot, tr:nth-child(even) { background: #eee }

@page { margin: 0; }
@media print {
.remark-slide-scaler {
width: 100% !important;
Expand Down

0 comments on commit 3e4eee0

Please sign in to comment.