如何在 LaTeX/PDF 中重新定义标准簿记 "theorem environment"?

How can I redefine a standard bookdown "theorem environment" in LaTeX/PDF?

我正在使用 bookdown,希望 PDF 版本中的标准 "example" 和 "definition" environments(例如)能够更清楚地区分,例如,添加一些轻微的背景阴影。

我该怎么做?我什至找不到这些环境的定义位置(例如 preamble.tex 中没有定义)。

一辉的书says

"If you are a LaTeX or HTML expert, you may want to customize the style of these environments anyway (see Chapter 4). "

这意味着这是可能的。我已阅读该部分,但我仍在挣扎(因此 post):显然我不是专家!

例如,为了测试我想做的事情是否可行,我尝试了一些非常简单的开始;我将此添加到 preamble.tex:

\makeatletter
\renewenvironment{example}
               {\begin{quote}}
               {\end{quote}}
\makeatother

LaTeX 编译报告:

! LaTeX Error: Environment example undefined.

所以它可能根本不是标准环境。事实上,这本书暗示它也许是一个定理。但是我不知道如何重新定义一个定理...

那么有没有办法为 PDF 输出重新定义这些标准块(如果是,如何)?

P.

标准块是环境,但它们是在您的自定义序言之后定义的。使用 \AtBeginDocument 您可以将自己的更改移到该定义之外:

---
output: 
  bookdown::pdf_document2:
      keep_tex: yes
header-includes:
- \AtBeginDocument{\renewenvironment{example}{\begin{quote}}{\end{quote}}}
---

# Some section

```{example}
Here is my example.
```

```{definition}
Here is my definition.
```

备注:

  • 我正在使用 header-includes 而不是 preamble.tex,但这应该无关紧要。
  • keep_tex: yes对分析这样的事情很有帮助
  • 这些环境是使用 LaTeX 包创建的 amsthm。它可能会提供更方便的自定义挂钩。