knit error when trying to compile PDF for bookdown

Hi folks. I posted this to GitHub, but a contributor there advised me to try this forum :slight_smile:

I run a blogdown site and was trying to include a bookdown article in the static folder, similar as if you would do with xaringan slides.

My goals are:

  1. Have a online version (Gitbook)
  2. Output a paper-ish PDF version

Current problems:

  1. When compiling to Gitbook, some config 's are not effective (no PDF download, no search)
  2. When compiling to PDF, knit gives the following error (fatal):
Error in if (toc) { : argument is not interpretable as logical
Calls: <Anonymous> ... get_base_format -> do.call -> <Anonymous> -> pandoc_toc_args
Execution halted

Any help is appreciated!


Files & code:

Summary

_output.yml:

bookdown::gitbook:
  split_by: none
  config:
    download: [pdf]
    sharing:
      github: yes
      facebook: no
    toolbar:
      search: yes
bookdown::pdf_document2:
  latex_engine: pdflatex
  keep_tex: yes
  fig_crop: false
  template: null
  toc: true
  toc_depth: 3
  number_sections: true
  highlight_bw: true

_bookdown.yml:

book_filename: quals
output_dir: output

head of paper.Rmd:

---
title: 'A Paper'
author: "loikein"
date: "Last updated: `r (Sys.time())`"
documentclass: article
knit: "bookdown::pdf_document2"
site: bookdown::bookdown_site
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(collapse = FALSE, tidy = FALSE, echo = TRUE, eval = FALSE)
```

# Abstract {-}

# Introduction

Some system info:

$ latex --version
pdfTeX 3.14159265-2.6-1.40.20 (TeX Live 2019)

─ Session info ────────────────────────────────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 3.6.2 (2019-12-12)
 os       macOS Catalina 10.15.3      
 system   x86_64, darwin15.6.0        
 ui       RStudio                     
 language (EN)                        
 collate  en_US.UTF-8                 
 ctype    en_US.UTF-8                 
 tz       Europe/Berlin               
 date     2020-02-07                  

─ Packages ────────────────────────────────────────────────────────────────────────────────────────────
 package   * version date       lib source        
 base64enc   0.1-3   2015-07-28 [1] CRAN (R 3.6.0)
 digest      0.6.23  2019-11-23 [1] CRAN (R 3.6.0)
 evaluate    0.14    2019-05-28 [1] CRAN (R 3.6.0)
 glue        1.3.1   2019-03-12 [1] CRAN (R 3.6.0)
 highr       0.8     2019-03-20 [1] CRAN (R 3.6.0)
 htmltools   0.4.0   2019-10-04 [1] CRAN (R 3.6.0)
 jsonlite    1.6     2018-12-07 [1] CRAN (R 3.6.0)
 knitr       1.27    2020-01-16 [1] CRAN (R 3.6.0)
 magrittr    1.5     2014-11-22 [1] CRAN (R 3.6.0)
 markdown    1.1     2019-08-07 [1] CRAN (R 3.6.0)
 mime        0.8     2019-12-19 [1] CRAN (R 3.6.0)
 Rcpp        1.0.3   2019-11-08 [1] CRAN (R 3.6.0)
 rlang       0.4.2   2019-11-23 [1] CRAN (R 3.6.0)
 rmarkdown   2.0     2019-12-12 [1] CRAN (R 3.6.0)
 stringi     1.4.5   2020-01-11 [1] CRAN (R 3.6.0)
 stringr     1.4.0   2019-02-10 [1] CRAN (R 3.6.0)
 tinytex     0.19    2020-01-14 [1] CRAN (R 3.6.0)
 xfun        0.12    2020-01-13 [1] CRAN (R 3.6.0)
 yaml        2.2.1   2020-02-01 [1] CRAN (R 3.6.2)

[1] /Library/Frameworks/R.framework/Versions/3.6/Resources/library

Ok, it turns out the problem was made up of some user errors and some bugs (?). Now that I have cleared up a bit, let me give an updated version of the problem:

Any LaTeX-related files only exist if I put bookdown::pdf_book:… before bookdown::gitbook:… in _output.yml, and once I do that, the .tex file re-renders, the .log refreshes, does not render PDF, and the .html file does not refresh.

If on the contrary, I put bookdown::gitbook:… before bookdown::pdf_book:… in _output.yml, then only the .html rerenders, and nothing happens to the LaTeX files.

.log
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (TeX Live 2019) (preloaded format=pdflatex 2019.11.5)  14 FEB 2020 18:52
entering extended mode
 restricted \write18 enabled.
 %&-line parsing enabled.
**paper.tex
(./paper.tex
LaTeX2e <2019-10-01> patch level 1
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/article.cls
Document Class: article 2019/12/20 v1.4l Standard LaTeX document class
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2019/12/20 v1.4l Standard LaTeX file (size option)
)
...

LaTeX Info: Redefining \[ on input line 2859.
LaTeX Info: Redefining \] on input line 2860.
) (/usr/local/texlive/2019/texmf-dist/tex/generic/iftex/ifxetex.sty
Package: ifxetex 2019/10/25 v0.7 ifxetex legacy package. Use iftex instead.
(/usr/local/texlive/2019/texmf-dist/tex/generic/iftex/iftex.sty
Package: iftex 2019/11/07 v1.0c TeX engine tests
)) (/usr/local/texlive/2019/texmf-dist/tex/generic/iftex/ifluatex.sty
Package: ifluatex 2019/10/25 v1.5 ifluatex legacy package. Use iftex instead.
) (/usr/local/texlive/2019/texmf-dist/tex/latex/base/fontenc.sty
Package: fontenc 2020/02/11 v2.0o Standard LaTeX package
(/usr/local/texlive/2019/texmf-dist/tex/latex/base/t1enc.def
File: t1enc.def 2020/02/11 v2.0o Standard LaTeX file
LaTeX Font Info:    Redeclaring font encoding T1 on input line 48.
)
LaTeX Font Info:    Trying to load font information for T1+lmr on input line 11
2.
(/usr/local/texlive/2019/texmf-dist/tex/latex/lm/t1lmr.fd
File: t1lmr.fd 2009/10/30 v1.6 Font defs for Latin Modern
)
! Undefined control sequence.
l.115 \xdef\@fontenc@load@list{\@fontenc@load@list
                                                   
Here is how much of TeX's memory you used:
 2070 strings out of 492167
 23632 string characters out of 6125389
 81348 words of memory out of 5000000
 6479 multiletter control sequences out of 15000+600000
 6630 words of font info for 15 fonts, out of 8000000 for 9000
 1141 hyphenation exceptions out of 8191
 30i,0n,31p,262b,78s stack positions out of 5000i,500n,10000p,200000b,80000s

!  ==> Fatal error occurred, no output PDF file produced!

Currently, I am using _render.R and Makefile from the bookdown repo as is, and other files are:

Summary

paper.Rmd:

---
title: "A Paper"
author: "loikein"
date: "Last update: `r (Sys.Date())`"
knit: "bookdown::render_book"
documentclass: article
bibliography: ["paper.bib"]
biblio-style: apalike
link-citations: yes
site: bookdown::bookdown_site
description: "A class paper."
bookdown:
  book_filename: research-paper
---

# Test 44

Cite test: @kogan_technological_2017

# Reference {-}

_output.yml:

bookdown::gitbook:
  split_by: none
  config:
    search: yes
    download: ["pdf"]
    sharing:
      github: yes
      facebook: no

bookdown::pdf_book:
  keep_tex: yes
  latex_engine: pdflatex
  citation_package: biblatex
  template: null

paper.bib:

@article{kogan_technological_2017,
	title = {Technological Innovation, Resource Allocation, and Growth},
	volume = {132},
	issn = {0033-5533},
	url = {https://academic.oup.com/qje/article/132/2/665/3076284},
	doi = {10.1093/qje/qjw040},
	abstract = {Abstract.  We propose a new measure of the economic importance of each innovation. Our measure uses newly collected data on patents issued to U.S. firms in the},
	language = {en},
	number = {2},
	urldate = {2020-02-12},
	journal = {The Quarterly Journal of Economics},
	author = {Kogan, Leonid and Papanikolaou, Dimitris and Seru, Amit and Stoffman, Noah},
	month = may,
	year = {2017},
	pages = {665--712},
	file = {Full Text PDF:/Users/loikein/Zotero/storage/QCX3WK8U/Kogan 等。 - 2017 - Technological Innovation, Resource Allocation, and.pdf:application/pdf;Snapshot:/Users/loikein/Zotero/storage/2BMMGFGK/3076284.html:text/html}
}
1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.