Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add downloadable book version? #27

Open
apreshill opened this issue Aug 10, 2019 · 12 comments
Open

add downloadable book version? #27

apreshill opened this issue Aug 10, 2019 · 12 comments

Comments

@apreshill
Copy link
Contributor

Hey @njtierney,

Not that you need to-you could disable that option all together. But you can add an epub or pdf version to your .travis.yml like this example:

https://github.com/tidyverse/style/blob/e2d76307a7ec8feecb4b3da72501687b7f4ba770/.travis.yml#L17-L18

I would offer a PR but I don't know tic and am afraid of screwing up your build!

Alison

@njtierney
Copy link
Owner

Heya @apreshill 👋

Ah, the broken download link has been bothering me for a while! Thank you for this. Let's see how it goes.

😄

@njtierney
Copy link
Owner

well this failed in a way I was not expecting: https://travis-ci.org/njtierney/rmd4sci/builds/570664147#L1252

24.19s$ Rscript -e "bookdown::render_book('index.Rmd', 'bookdown::pdf_book', quiet = TRUE)"
!!! Error: Ghostscript exited with error code 127!
!!! Error: Ghostscript exited with error code 127!

Have you seen that error before?

Also, I used to use tic, but once you showed me your recipe for getting bookdown to publish via netlify it worked a charm, and I removed tic. https://github.com/njtierney/rmd4sci/search?q=tic&type=Code

@apreshill
Copy link
Contributor Author

apreshill commented Aug 12, 2019

Blurg! No I haven't seen it, but a google search suggests (to me) that Ghostscript may be associated with the PDF output. When I tried to build the PDF book locally, I fail with this error:

tlmgr search --file --global '/Source Code Pro[.](tfm|afm|mf|otf)'
! Package fontspec Error: The font "Source Code Pro" cannot be found.

! kpathsea:make_tex: Invalid filename `Source Code Pro', contains ' '

Error: Failed to compile rmd4sci.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See rmd4sci.log for more info.
In addition: Warning message:
In parse_packages(logfile, quiet = c(TRUE, FALSE, FALSE)) :
  Failed to find a package that contains Source Code Pro[.](tfm|afm|mf|otf)
Execution halted

Exited with status 1.

I would bet if you removed that build from your script it would work.

@njtierney
Copy link
Owner

Ah, thanks for tracing that issue down, @apreshill :)

Let's see how this one goes.

@njtierney
Copy link
Owner

OK so removing the PDF build fixed it 🎉

Next steps will be getting the PDF build working and the MOBI version as well.

@murraycadzow
Copy link
Contributor

murraycadzow commented Jul 29, 2020

I just ran into the same issue as @apreshill plus a few other fonts seemed to be missing on my machine when building but found that this managed to solve it for me (on ubuntu)

mkdir ~/.fonts
git clone git://github.com/google/fonts.git ~/.fonts/google-fonts 
fc-cache -f

from https://gist.github.com/keeferrourke/d29bf364bd292c78cf774a5c37a791db#gistcomment-2716262

@yihui
Copy link

yihui commented Sep 9, 2020

!!! Error: Ghostscript exited with error code 127!

@njtierney Here is the fix to this issue: rstudio/bookdown-demo@ae54659

njtierney added a commit that referenced this issue Sep 9, 2020
@njtierney
Copy link
Owner

Thanks, @yihui - it works for EPUB now, but it looks like PDF causes some issues still: https://travis-ci.org/github/njtierney/rmd4sci/jobs/725481117#L4502

50% there though, thanks for your help, @yihui :)

@yihui
Copy link

yihui commented Sep 9, 2020

The problem that you mentioned seems to be for EPUB instead of PDF.

[WARNING] Could not convert TeX math '
  Y \sim X\beta_0 + X\beta_1 + \epsilon \tag{1}
  ', rendering as TeX:
  
                     ^
  unexpected "{"
  expecting "%", "\\label", "\\nonumber" or whitespace
[1] "/home/travis/build/njtierney/rmd4sci/_book/rmd4sci.epub"

It was caused by \tag{}:

$$
Y \sim X\beta_0 + X\beta_1 + \epsilon \tag{1}
$$

I don't know why Pandoc doesn't support \tag{}. Perhaps you can drop this way of providing equation numbers, and only mention the first way.

@yihui
Copy link

yihui commented Sep 9, 2020

You didn't seem to build PDF at all:

# - Rscript -e "bookdown::render_book('index.Rmd', 'bookdown::pdf_book', quiet = TRUE)"

@njtierney
Copy link
Owner

Ack, sorry for that, @yihui, thanks for being a fresh pair of eyes. I'll more thoroughly read my travis build next time 🙂

@yihui
Copy link

yihui commented Sep 10, 2020

To be able to build PDF, you have to either delete the font specifications (i.e. use default fonts):

rmd4sci/index.Rmd

Lines 13 to 14 in 059dd5a

monofont: "Source Code Pro"
monofontoptions: "Scale=0.7"

\setmainfont[UprightFeatures={SmallCapsFont=AlegreyaSC-Regular}]{Alegreya}

or actually install the fonts, e.g. follow @murraycadzow's tip above. Cloning and installing all Google Fonts sounds like an overkill to me, since you only need two of them. If I were you, I won't bother doing this.

The third option is to use fonts available on Ubuntu, and I believe there are many, but the downside is for people who do not use Ubuntu, they may not be able to build PDF by themselves. It depends on how much you really care about the typefaces in PDF.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants