【问题标题】:Bookdown to PDF Theorem Environment DuplicateBookdown 到 PDF 定理环境副本
【发布时间】:2020-05-20 21:10:21
【问题描述】:

我正在做一个 bookdown 项目,但遇到了定理环境的问题。当我编译为 gitbook、epub_book 或 tufte_html_book 但编译为 pdf_book 时,它可以工作。以下是我的 index.Rmd 文件中的内容

--- 
title: "Blah Blah"
author: "Me"
date: "`r Sys.Date()`"
site: bookdown::bookdown_site
documentclass: krantz
bibliography: [book.bib, packages.bib]
biblio-style: apalike
link-citations: yes
description: "This is a minimal example of using the bookdown package to write a book. The output format for this example is bookdown::gitbook."
header-includes:
- \usepackage{amsthm}
- \newtheorem{definition}{Definition}
- \newtheorem{lemma}{Lemma}
- \newtheorem{theorem}{Theorem}
- \newtheorem{example}{Example}
---

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

# First Chapter

The content of Preface. [@xie2015]

```{theorem, name="Infinite Group"}
A group having an infinite number of elements.
```

```{example}
The set $(\mathbb{Z}, +)$ is an infinite group.
```

这是我的 _output.yml 文件(相关部分)中的内容:

bookdown::pdf_book:
  includes:
    in_header: preamble.tex
  latex_engine: xelatex
  citation_package: natbib
  keep_tex: yes
  pandoc_args: --top-level-division=chapter

preamble.tex 只包含 \usepackage{booktabs}

这是我编译时得到的:

似乎定理的名称和实际内容被视为两个不同的定理,以及示例。这在定义和引理方面是相同的。即使我删除

header-includes:
    - \usepackage{amsthm}
    - \newtheorem{definition}{Definition}
    - \newtheorem{lemma}{Lemma}
    - \newtheorem{theorem}{Theorem}
    - \newtheorem{example}{Example}

从 yaml 标头中,我仍然遇到同样的问题。有关如何解决此问题的任何想法?

【问题讨论】:

    标签: r latex r-markdown bookdown


    【解决方案1】:

    这是一个已知的错误,has been fixedknitr 的开发版本中。你可以试试:

    remotes::install_github('yihui/knitr')
    install.packages('bookdown')  # update bookdown
    

    【讨论】:

    • 亲爱的@YihuiXie,这并没有为我解决 - 我仍然遇到问题.. 我点击了你的链接,指向你的 GitHub,如果我没记错的话,问题似乎是我没有使用最新版本的 Pandoc,对吗?我被困在旧版本的 Pandoc 上的原因是this unsolved SO post。是否有可能使您的解决方案 Pandoc 2.6 友好?非常感谢,托马斯
    猜你喜欢
    • 2020-05-09
    • 2017-10-12
    • 1970-01-01
    • 1970-01-01
    • 2011-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多