├── .gitignore ├── .gitlab-ci.yml ├── .travis.yml ├── 01-heaven.Rmd ├── 99-references.Rmd ├── DESCRIPTION ├── LICENSE ├── README.md ├── _bookdown.yml ├── _output.yml ├── book.bib ├── index.Rmd ├── packages.bib ├── pulp.css └── pulpdown.Rproj /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | pulpdown.html 6 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | image: rlesur/weasydoc:latest 2 | 3 | pages: 4 | stage: deploy 5 | script: 6 | - Rscript -e "devtools::install_github('rstudio/fontawesome')" 7 | - Rscript -e "bookdown::render_book('index.Rmd', 'all')" 8 | - mkdir public 9 | - mv pulpdown.pdf public/pulpdown.pdf 10 | artifacts: 11 | paths: 12 | - public 13 | only: 14 | - master 15 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | branches: 2 | only: 3 | - master 4 | language: r 5 | sudo: false 6 | cache: 7 | packages: yes 8 | pandoc_version: 2.2.1 9 | 10 | addons: 11 | apt: 12 | packages: 13 | - ttf-dejavu 14 | 15 | before_script: 16 | - wget https://www.princexml.com/download/prince_12-1_ubuntu14.04_amd64.deb 17 | - sudo dpkg -i prince_12-1_ubuntu14.04_amd64.deb 18 | - rm prince_12-1_ubuntu14.04_amd64.deb 19 | 20 | script: 21 | - Rscript -e "bookdown::render_book('index.Rmd', 'all')" 22 | - git config --global user.email "romain.lesur@gmail.com" 23 | - git config --global user.name "Romain Lesur" 24 | - git clone -b gh-pages https://${GITHUB_PAT}@github.com/${TRAVIS_REPO_SLUG}.git book-output 25 | - rm -f ./book-output/*.pdf 26 | - cp ./pulpdown.pdf ./book-output/pulpdown.pdf 27 | - cd book-output 28 | - git add --all -f ./* 29 | - git commit -m"Update pdf" 30 | - git push origin gh-pages 31 | -------------------------------------------------------------------------------- /01-heaven.Rmd: -------------------------------------------------------------------------------- 1 | # Highway to Heaven {#intro .unnumbered} 2 | 3 | This template relies only on HTML and CSS. All the styling rules are included in the `pulp.css` file. 4 | 5 | ## Build the book with GitLab {-} 6 | 7 | Since GitLab offers a git version control service and a CI/CD service in one application, the easiest way to build this book is to import this repository on GitLab^[see an example here: .]. 8 | Once imported, the book will be automatically built after each commit and you will find the pdf file in the artifacts folder^[see .] or directly using the url: `https://username.gitlab.io/repo/pulpdown.pdf`. 9 | 10 | ## Build the book with Travis {-} 11 | 12 | You need to modify the `.travis.yml` file to setup your email and name. 13 | As explained in @bookdown (see [chapter 6](https://bookdown.org/yihui/bookdown/github.html)), you have to grant Travis to write on your repository using the `GITHUB_PAT` environment variable. 14 | 15 | ## Build the book locally {-} 16 | 17 | If you prefer to build the book with your system, you have to install the development version of the weasydoc [@R-weasydoc] package and the Prince XML software (). 18 | 19 | ## Customize the template {-} 20 | 21 | All the styling is done using CSS rules. You will find some specific at-rules for pages layouts (`@page {...}`): these rules are defined by the CSS paged media modules. You can find some references on CSS paged media in the [weasydoc `README` file](https://github.com/RLesur/weasydoc#readme). 22 | 23 | This template is far from perfect. I think nobody will need it. I only hope you will be interested in CSS paged media. 24 | -------------------------------------------------------------------------------- /99-references.Rmd: -------------------------------------------------------------------------------- 1 | `r if (knitr::is_html_output()) ' 2 | # References {-} 3 | '` 4 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: pulpdown 2 | Type: Book 3 | Title: A Demo Template for Pulp Magazines with Bookdown. 4 | Version: 0.0.1 5 | Imports: bookdown, fontawesome, weasydoc 6 | Remotes: rstudio/fontawesome, RLesur/weasydoc 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Romain Lesur 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is the source of the `pulpdown` template for `bookdown`. 2 | 3 | You can see the book [here](https://rawgit.com/RLesur/pulpdown/gh-pages/pulpdown.pdf): open it with Acrobat Reader or equivalent. 4 | -------------------------------------------------------------------------------- /_bookdown.yml: -------------------------------------------------------------------------------- 1 | book_filename: "pulpdown" 2 | delete_merged_file: true 3 | 4 | -------------------------------------------------------------------------------- /_output.yml: -------------------------------------------------------------------------------- 1 | weasydoc::hpdf_document2: 2 | self_contained: true 3 | theme: null 4 | highlight: null 5 | toc: true 6 | keep_html: true 7 | notes: footnotes 8 | engine: prince 9 | css: pulp.css 10 | mathjax: null 11 | pandoc_args: ["--mathml"] 12 | -------------------------------------------------------------------------------- /book.bib: -------------------------------------------------------------------------------- 1 | @movie{pulpfiction, 2 | title = {Pulp Fiction}, 3 | producer= {Bender, Lawrence}, 4 | director = {Tarantino, Quentin}, 5 | year = {1994}, 6 | publisher = {Miramax} 7 | } 8 | @misc{latexisdead, 9 | author = {Xie, Yihui}, 10 | title = {In HTML and the Web I Trust}, 11 | titleaddon = {And LaTeX is dead}, 12 | type = {blog}, 13 | number = {July 30}, 14 | year = {2018}, 15 | howpublished = {\url{https://yihui.name/en/2018/07/in-html-i-trust/}} 16 | } 17 | @Book{bookdown, 18 | title = {bookdown: Authoring Books and Technical Documents with {R} 19 | Markdown}, 20 | author = {Yihui Xie}, 21 | publisher = {Chapman and Hall/CRC}, 22 | address = {Boca Raton, Florida}, 23 | year = {2016}, 24 | note = {ISBN 978-1138700109}, 25 | url = {https://github.com/rstudio/bookdown}, 26 | } 27 | -------------------------------------------------------------------------------- /index.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Pulp Down" 3 | subtitle: "A Demo Template with CSS for Paged Media" 4 | author: ["Romain Lesur", "R", "RMarkdown", "Bookdown", "Knitr", "Pandoc", "HTML", "CSS", "Prince"] 5 | abstract: | 6 | ::: {.headline} 7 | _TeX's Dead_ 8 | ::: 9 | Cover Image by Frank Black Noir [CC BY 2.0]( https://creativecommons.org/licenses/by/2.0), via Wikimedia Commons 10 | Advertisement: *Over There*, 1918, by Louis Fancher [Public domain], via Wikimedia Commons 11 | date: "October" 12 | site: bookdown::bookdown_site 13 | documentclass: book 14 | bibliography: [book.bib, packages.bib] 15 | biblio-style: apalike 16 | link-citations: yes 17 | --- 18 | 19 | ```{r echo=FALSE} 20 | knitr::opts_chunk$set(dev.args = list(bg = NA)) 21 | ``` 22 | 23 | # Confession {-} 24 | 25 | I gave up. Every time, _It_ has been stronger than me. 26 | 27 | Three times in my life, I painfully tried to control _It_. And there were always these warnings I should have understood! 28 | 29 | _It_ is so heavy, sprawling, mysterious and powerful. I knew, though, that if I did not use _It_, I would lose _It_. Actually, this is _It_ that lost me. 30 | 31 | I will never try to learn _LaTeX_ anymore, all of that is over. I will always be ilLaTeXerate and I am proud. 32 | 33 | I decided to follow a different path that many consider to be far from the utmost respect for the typesetting rules. 34 | 35 | I do not care because I have fun. 36 | 37 | Now, I am able to develop, with little efforts, this type of utterly useless template! For sure, nobody needs to write a pulp magazine with the **bookdown** package [@R-bookdown]. 38 | 39 | This template is a joke. My main motivation is to make it known that `r fontawesome::fa("r-project", fill="#785963")` users are not tied to LaTeX in order to produce good looking printed books. 40 | 41 | Having read _In HTML and the Web I Trust_ [@latexisdead], I wanted to make reference to a line from _Pulp Fiction_ [@pulpfiction] uttered by Butch Coolidge: that explains the choice of a pulp magazine. 42 | 43 | Believe me, there is a life after LaTeX. 44 | 45 | 46 | ```{r include=FALSE} 47 | # automatically create a bib database for R packages 48 | knitr::write_bib(c( 49 | .packages(), 'bookdown', 'weasydoc' 50 | ), 'packages.bib') 51 | ``` 52 | 53 | -------------------------------------------------------------------------------- /packages.bib: -------------------------------------------------------------------------------- 1 | @Manual{R-base, 2 | title = {R: A Language and Environment for Statistical Computing}, 3 | author = {{R Core Team}}, 4 | organization = {R Foundation for Statistical Computing}, 5 | address = {Vienna, Austria}, 6 | year = {2018}, 7 | url = {https://www.R-project.org/}, 8 | } 9 | @Manual{R-bookdown, 10 | title = {bookdown: Authoring Books and Technical Documents with R Markdown}, 11 | author = {Yihui Xie}, 12 | year = {2018}, 13 | note = {R package version 0.7}, 14 | url = {https://CRAN.R-project.org/package=bookdown}, 15 | } 16 | @Manual{R-weasydoc, 17 | title = {weasydoc: Convert R Markdown to PDF Using HTML and CSS}, 18 | author = {Romain Lesur}, 19 | note = {R package version 0.0.9000}, 20 | url = {https://github.com/RLesur/weasydoc}, 21 | year = {2018}, 22 | } 23 | -------------------------------------------------------------------------------- /pulp.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css?family=Vollkorn|Vollkorn+SC|Dancing+Script|Carter+One|Holtwood+One+SC|Source+Code+Pro|Merriweather+Sans:800'); 2 | 3 | @page { 4 | font-family: 'Merriweather Sans'; 5 | color: #785963; 6 | font-size: 12pt; 7 | text-transform: uppercase; 8 | } 9 | 10 | @page:left { 11 | background-image: url('https://upload.wikimedia.org/wikipedia/commons/thumb/4/4f/Old_paper1.jpg/768px-Old_paper1.jpg'); 12 | background-repeat: no-repeat; 13 | background-size: cover; 14 | filter: opacity(47%); 15 | @bottom-left { 16 | content: counter(page); 17 | } 18 | @bottom-right { 19 | content: string(magazine); 20 | } 21 | } 22 | 23 | @page:right { 24 | background-image: url('https://upload.wikimedia.org/wikipedia/commons/thumb/1/1f/Old_paper3.jpg/768px-Old_paper3.jpg'); 25 | background-repeat: no-repeat; 26 | background-size: cover; 27 | filter: opacity(50%); 28 | @bottom-left { 29 | content: string(chapter); 30 | } 31 | @bottom-right { 32 | content: counter(page); 33 | } 34 | } 35 | 36 | @page:blank { 37 | background-image: url('https://upload.wikimedia.org/wikipedia/commons/d/d4/Over_there_Louis_Fancher.jpg'); 38 | background-size: cover; 39 | filter: opacity(100%); 40 | @bottom-left { 41 | content: ""; 42 | } 43 | @bottom-right { 44 | content: ""; 45 | } 46 | } 47 | 48 | @page:first { 49 | margin: 25mm 0 0 0; 50 | background-color: #11161c; 51 | background-image: 52 | radial-gradient(36px at 28mm 77mm , #DEA642 0%, #DEA642 30px, black 32px, #ab8864 34px, black 35px, rgba(255,255,255,0) 36px), 53 | linear-gradient(rgba(0, 0, 0, 0) 220mm, rgba(17, 22, 28, 0.8) 240mm), 54 | url('https://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/PulpFictionPosterSpoof.jpg/657px-PulpFictionPosterSpoof.jpg'), 55 | linear-gradient(#c75140 74mm, #11161c 74mm); 56 | background-repeat: no-repeat; 57 | background-position: bottom right; 58 | filter: blur(0.5px) sepia(75%) saturate(80%); 59 | background-size: cover, cover, 657px 768px, cover; 60 | 61 | @top-center { 62 | content: "First Bookdown Contest"; 63 | font-family: 'Holtwood One SC'; 64 | font-size: 18pt; 65 | color: black; 66 | letter-spacing: 2pt; 67 | } 68 | } 69 | 70 | @page toc { 71 | @bottom-right { 72 | content: ""; 73 | } 74 | @bottom-left { 75 | content: ""; 76 | } 77 | } 78 | 79 | div.abstract { 80 | page-break-before: avoid; 81 | page-break-after: always; 82 | } 83 | 84 | @media print { 85 | html { 86 | color: #785963; 87 | font-size: 16pt; 88 | font-family: 'Vollkorn'; 89 | font-weight: 600; 90 | text-align: justify; 91 | text-justify: inter-word; 92 | counter-reset: chapter-number; 93 | } 94 | code, kbd, listing, plaintext, pre, samp, tt, xmp { 95 | font-family: 'Source Code Pro'; 96 | font-size: 14pt; 97 | font-weight: 600; 98 | } 99 | h3.subtitle { 100 | text-align: center; 101 | font-family: 'Carter one'; 102 | font-size: 12pt; 103 | color: black; 104 | font-weight: bold; 105 | transform: scale(1, 2.2); 106 | transform-origin: top; 107 | margin-top: 20mm; 108 | line-height: 15pt; 109 | bookmark-level: none; 110 | } 111 | h1.title { 112 | text-align: center; 113 | font-family: 'Holtwood One SC'; 114 | color: #ecce5e; 115 | font-size: 62pt; 116 | font-weight: bold; 117 | transform: scale(1, 2.2); 118 | transform-origin: top; 119 | margin-top: 8mm; 120 | line-height: 15pt; 121 | string-set: magazine content(); 122 | bookmark-level: none; 123 | } 124 | div.headline { 125 | font-family: 'Holtwood One SC'; 126 | font-size: 40pt; 127 | color: rgba(248,239,226,0.8); 128 | position: fixed; 129 | bottom: 24mm; 130 | right: 10mm; 131 | } 132 | h4.author:first-of-type { 133 | color: #ab8864; 134 | font-family: 'Dancing Script'; 135 | font-size: 13pt; 136 | padding-bottom: 1mm; 137 | border-bottom: 2pt solid #ab8864; 138 | width: 23mm; 139 | text-transform: none; 140 | } 141 | h4.author:first-of-type:before { 142 | content: "designed by"; 143 | display: block; 144 | margin-top: 23mm; 145 | font-size: 12pt; 146 | text-transform: none; 147 | } 148 | h4.author:nth-of-type(2):before { 149 | content: "Credits"; 150 | font-family: 'Carter one'; 151 | font-weight: normal; 152 | font-size: 18pt; 153 | display: block; 154 | padding-bottom: 4mm; 155 | text-transform: none; 156 | } 157 | h4.author { 158 | margin-left: 19mm; 159 | font-family: 'Holtwood One SC'; 160 | color: #ecce5e; 161 | font-size: 16pt; 162 | text-transform: none; 163 | bookmark-level: none; 164 | } 165 | h4.date { 166 | position: absolute; 167 | right: 5mm; 168 | top: 34mm; 169 | color: #ccc; 170 | font-family: 'Holtwood One SC'; 171 | text-transform: none; 172 | bookmark-level: none; 173 | } 174 | h4.date:after { 175 | font-family: 'Dancing Script'; 176 | content: "Free"; 177 | display: block; 178 | position: fixed; 179 | left: 23mm; 180 | top: 47mm; 181 | font-size: 20pt; 182 | color: black; 183 | font-weight: bold; 184 | text-transform: none; 185 | } 186 | div.abstract { 187 | color: #999; 188 | position: fixed; 189 | font-family: 'Holtwood One SC'; 190 | top : 235mm; 191 | text-align: center; 192 | font-size: 8pt; 193 | width: 100%; 194 | } 195 | p.abstract { 196 | display: none; 197 | } 198 | .abstract a { 199 | color: #999; 200 | text-decoration: none; 201 | } 202 | h1, h2, h3, h4, h5, h6 { 203 | font-family: 'Vollkorn SC'; 204 | } 205 | .section.level1 { 206 | page-break-before: always; 207 | } 208 | .section.level1 > h1 { 209 | string-set: chapter content(); 210 | } 211 | .columns-2 { 212 | column-count: 2; 213 | } 214 | pre { 215 | page-break-inside: avoid; 216 | padding-left: 2mm; 217 | border-left: 2pt solid #785963; 218 | } 219 | a { 220 | color: #90666a; 221 | text-decoration: none; 222 | } 223 | a.uri { 224 | hyphens: manual; 225 | } 226 | #TOC { 227 | page-break-before: right; 228 | page: toc; 229 | text-transform: uppercase; 230 | } 231 | #TOC::before { 232 | content: string(magazine); 233 | display: block; 234 | position: fixed; 235 | top: 20mm; 236 | text-transform: uppercase; 237 | font-size: 40pt; 238 | font-weight: 900; 239 | font-family: 'Merriweather Sans'; 240 | } 241 | #TOC ul { 242 | padding-bottom: 0; 243 | padding-top: 0; 244 | } 245 | #TOC>ul { 246 | width: 60%; 247 | margin-top: 55mm; 248 | padding: 4mm 0 4mm 10mm; 249 | float: right; 250 | border-left: 2mm solid #785963; 251 | } 252 | #TOC li { 253 | padding-top: 2mm; 254 | padding-bottom: 2mm; 255 | } 256 | #TOC li:first-of-type { 257 | padding-top: 4mm; 258 | } 259 | .section p { 260 | text-indent: 22pt; 261 | } 262 | .section>p:first-of-type { 263 | text-indent:0; 264 | } 265 | .section>p:first-of-type::first-letter { 266 | font-size: 1.5rem; 267 | font-weight: bolder; 268 | } 269 | 270 | } -------------------------------------------------------------------------------- /pulpdown.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | BuildType: Website 16 | --------------------------------------------------------------------------------