bookdown 将章节转换为章节

top*_*epo 5 latex r bookdown

我有一本书可以很好地编译为 html,但 pdf 版本没有章节。例如,命令

# Introduction {#intro-intro}
Run Code Online (Sandbox Code Playgroud)

被翻译成

\hypertarget{intro-intro}{%
\section{Introduction}\label{intro-intro}}
Run Code Online (Sandbox Code Playgroud)

(gitbook 格式没有这样的问题)

<EDIT>

# Preface {-}在顶部Index.Rmd\mainmatter最后。也许它没有脱离序言?罗马数字在 处变回非罗马数字# Introduction

</EDIT>

我的Index.Rmd

---
documentclass: krantz
classoption: numberinsequence
bibliography: [book.bib]
biblio-style: apalike
link-citations: yes
colorlinks: yes
graphics: yes
---
Run Code Online (Sandbox Code Playgroud)

_bookdown.yml

new_session: yes    
output_dir: working_files
clean: [bookdown.bbl]
language:
  label:
    fig: "Fig. "
    tab: "Table "
Run Code Online (Sandbox Code Playgroud)

并且_output.yml

  bookdown::gitbook:
    css: css/style.css
    dev: svglite

  bookdown::pdf_book:
    includes:
      in_header: latex_extras/preamble.tex
      before_body: latex_extras/before_body.tex
      after_body: latex_extras/after_body.tex
    keep_tex: yes
    dev: "cairo_pdf"
    latex_engine: pdflatex
    citation_package: natbib
    template: null
    toc_unnumbered: no
    toc_appendix: yes
    quote_footer: ["\\VA{", "}{}"]
Run Code Online (Sandbox Code Playgroud)

最后

  > session_info()
  ? Session info ???????????????????????????????????????????????????????????????
  setting  value                       
  version  R version 3.4.3 (2017-11-30)
  os       macOS High Sierra 10.13.3   
  system   x86_64, darwin15.6.0        
  ui       X11                         
  language (EN)                        
  collate  en_US.UTF-8                 
  tz       America/New_York            
  date     2018-03-09                  

  ? Packages ???????????????????????????????????????????????????????????????????
  package     * version date       source         
  backports     1.1.2   2017-12-13 CRAN (R 3.4.3) 
  bookdown    * 0.7     2018-02-18 CRAN (R 3.4.3) 
  clisymbols    1.2.0   2017-05-21 CRAN (R 3.4.0) 
  digest        0.6.15  2018-01-28 cran (@0.6.15) 
  evaluate      0.10.1  2017-06-24 CRAN (R 3.4.1) 
  htmltools     0.3.6   2017-04-28 CRAN (R 3.4.0) 
  knitr         1.20    2018-02-20 CRAN (R 3.4.3) 
  magrittr      1.5     2014-11-22 CRAN (R 3.4.0) 
  Rcpp          0.12.15 2018-01-20 cran (@0.12.15)
  rmarkdown   * 1.8     2017-11-17 CRAN (R 3.4.2) 
  rprojroot     1.3-2   2018-01-03 cran (@1.3-2)  
  sessioninfo * 1.0.0   2017-06-21 CRAN (R 3.4.1) 
  stringi       1.1.6   2017-11-17 CRAN (R 3.4.2) 
  stringr       1.3.0   2018-02-19 CRAN (R 3.4.3) 
  withr         2.1.1   2017-12-19 CRAN (R 3.4.3) 
  xfun          0.1     2018-01-22 cran (@0.1)    
Run Code Online (Sandbox Code Playgroud)

Yih*_*Xie 1

Pandoc默认转换#为(不严格正确,但详细信息请参阅Pandoc手册)。为了让它知道你想要章节,你必须使用参数(示例在这里)。\section{}--top-level-division