作者:Yihui Xie
译者:郑宝童
日期:2021.05.18


3 Output Formats

The bookdown package primarily supports three types of output formats: HTML, LaTeX/PDF, and e-books. In this chapter, we introduce the possible options for these formats. Output formats can be specified either in the YAML metadata of the first Rmd file of the book, or in a separate YAML file named _output.yml under the root directory of the book. Here is a brief example of the former (output formats are specified in the output field of the YAML metadata):

bookdown包主要支持三种输出格式:HTML、LaTeX/PDF和电子书。在本章中,我们将介绍这些格式的可能的选项。输出格式可以在书的第一个Rmd文件的YAML元数据中指定,也可以在书籍根目录下名为 _output.yml的单独YAML文件中指定。下面是前者的一个简单示例(输出格式在output的YAML元数据字段中指定):

  1. ---
  2. title: "An Impressive Book"
  3. author: "Li Lei and Han Meimei"
  4. output:
  5. bookdown::gitbook:
  6. lib_dir: assets
  7. split_by: section
  8. config:
  9. toolbar:
  10. position: static
  11. bookdown::pdf_book:
  12. keep_tex: yes
  13. bookdown::html_book:
  14. css: toc.css
  15. documentclass: book
  16. ---

Here is an example of _output.yml:

这里展示一个 _output.yml的;例子:

  1. bookdown::gitbook:
  2. lib_dir: assets
  3. split_by: section
  4. config:
  5. toolbar:
  6. position: static
  7. bookdown::pdf_book:
  8. keep_tex: yes
  9. bookdown::html_book:
  10. css: toc.css

In this case, all formats should be at the top level, instead of under an output field. You do not need the three dashes --- in _output.yml.
在这种情况下,所有格式都应该在顶层,而不是在output 字段下。您不需要在_output.yml.中使用三个破折号 ---