Skip to content

Commit 7149754

Browse files
Merge pull request #282 from UBC-DSCI/pdf
pdf
2 parents 54e6a34 + 31d62b6 commit 7149754

39 files changed

+3340
-726
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@
77
_bookdown_files
88
**.ipynb_checkpoints
99
.rstudio/*
10+
pdf/_book
11+
pdf/_bookdown_files
12+
pdf/*.log

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,19 @@ We provide instructions for both methods here.
2020

2121
To build the **html version** of the book, navigate to the repository root folder and run
2222
```
23-
./build.sh
23+
./build_html.sh
2424
```
2525
from the command line. This command automatically spawns a docker container
26-
with the `ubcdsci/intro-to-ds` image, runs the script `build.R` from within the container,
27-
and then stops the container. It may ask you for a password; this is the password for the
28-
`sudo` command on your computer. Typically this is just your usual computer user account password.
29-
But if your setup doesn't require you to use `sudo` to start a docker container, you can just
30-
open `build.sh` and delete the word `sudo` at the start of the script.
26+
with the `ubcdsci/intro-to-ds` image, runs the script `_build_html.r` from within the container,
27+
and then stops the container.
3128

3229
To build the **PDF version** of the book, instead run
3330
```
34-
./pdfbuild.sh
31+
./build_pdf.sh
3532
```
36-
The same comments regarding passwords and `sudo` as above apply here.
33+
This command again spawns a docker container and runs `pdf/_build_pdf.r` inside the container.
3734

38-
### With RStudio
35+
### With RStudio (HTML only)
3936

4037
1. Run RStudio inside the `ubcdsci/intro-to-ds` docker container:
4138
- in terminal, navigate to the root of this project repo
@@ -127,16 +124,19 @@ bookdown::gitbook:
127124
- make sure all figures get (capitalized) labels ("Figure \\@ref(blah)", not "figure below" or "figure above")
128125
- make sure all figures get captions
129126
- specify image widths in terms of linewidth percent (e.g. `out.width="70%"`)
130-
- center align all images
127+
- center align all images via `fig.align = "center"`
131128
- make sure we have permission for every figure/logo that we use
132129
- Make sure all figures follow the visualization principles in Chapter 4
133130
- Make sure axes are set appropriately to not inflate/deflate differences artificially *where it does not compromise clarity* (e.g. in the classification
134131
chapter there are a few examples where zoomed-in accuracy axes are better than using the full range 0 to 1)
132+
-
135133

136134
#### Tables
137135
- make sure all tables get capitalized labels ("Table \\@ref(blah)", not "table below" or "table above")
138136
- make sure all tables get captions
139137
- make sure the row + column spacing is reasonable
138+
- Do not put links in table captions, it breaks pdf rendering
139+
- Do not put underscores in table captions, it breaks pdf rendering
140140

141141
#### Note boxes
142142
- note boxes should be typeset as quote boxes using `>` and start with **Note:**
@@ -178,6 +178,10 @@ Generally the book uses American spelling. Some common British vs American and C
178178
- c vs s: defense (not defence)
179179
- er vs re: center (not centre)
180180

181+
#### Whitespace
182+
We need a line of whitespace before and after code fences (code surrounded by three backticks above and below). This is for readability,
183+
and it is essential for figure captions.
184+
181185
#### PDF Output
182186
These are absolute last steps when rendering the PDF output:
183187
- Look for and fix bad line breaks (e.g. with only one word on the next line, orphans, and widows)

_build.R renamed to _build_html.r

File renamed without changes.

_pdfbuild.R

Lines changed: 0 additions & 1 deletion
This file was deleted.

build.sh

Lines changed: 0 additions & 1 deletion
This file was deleted.

build_html.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Script to generate HTML book
2+
docker run --rm -m 4g -v $(pwd):/home/rstudio/introduction-to-datascience ubcdsci/intro-to-ds:v0.12.0 /bin/bash -c "cd /home/rstudio/introduction-to-datascience; Rscript _build_html.r"

build_pdf.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Script to generate PDF book
2+
3+
# Copy files
4+
cp references.bib pdf/
5+
cp preface-text.Rmd pdf/
6+
cp intro.Rmd pdf/
7+
cp reading.Rmd pdf/
8+
cp wrangling.Rmd pdf/
9+
cp viz.Rmd pdf/
10+
cp classification1.Rmd pdf/
11+
cp classification2.Rmd pdf/
12+
cp regression1.Rmd pdf/
13+
cp regression2.Rmd pdf/
14+
cp clustering.Rmd pdf/
15+
cp inference.Rmd pdf/
16+
cp jupyter.Rmd pdf/
17+
cp version-control.Rmd pdf/
18+
cp setup.Rmd pdf/
19+
cp references.Rmd pdf/
20+
cp printindex.tex pdf/
21+
cp -r data/ pdf/
22+
cp -r img/ pdf/
23+
24+
# Build the book with bookdown
25+
docker run --rm -m 4g -v $(pwd):/home/rstudio/introduction-to-datascience ubcdsci/intro-to-ds:v0.12.0 /bin/bash -c "cd /home/rstudio/introduction-to-datascience/pdf; Rscript _build_pdf.r"
26+
27+
# clean files in pdf dir
28+
rm -rf pdf/references.bib
29+
rm -rf pdf/preface-text.Rmd
30+
rm -rf pdf/intro.Rmd
31+
rm -rf pdf/reading.Rmd
32+
rm -rf pdf/wrangling.Rmd
33+
rm -rf pdf/viz.Rmd
34+
rm -rf pdf/classification1.Rmd
35+
rm -rf pdf/classification2.Rmd
36+
rm -rf pdf/regression1.Rmd
37+
rm -rf pdf/regression2.Rmd
38+
rm -rf pdf/clustering.Rmd
39+
rm -rf pdf/inference.Rmd
40+
rm -rf pdf/jupyter.Rmd
41+
rm -rf pdf/version-control.Rmd
42+
rm -rf pdf/setup.Rmd
43+
rm -rf pdf/references.Rmd
44+
rm -rf pdf/printindex.tex
45+
rm -rf pdf/data pdf/img
46+

0 commit comments

Comments
 (0)