Ach*_*eis 8 pandoc r-markdown quarto
我正在quarto写一本在线书籍,需要模仿已出版书籍的环境和柜台。后者采用五个自定义框架环境(示例、练习、评论、定理、定义)以及一个联合计数器(在章节内)。
我正在考虑为这些使用现成的标注块,因为默认情况下它们的样式非常漂亮。不过,我还没有成功为这些标注块创建自定义计数器,以便我可以从文本中交叉引用。有办法这样做吗?
(备注:我还尝试通过 提供的标准 amsthm 环境来执行此操作quarto,请参阅四开本中的共享计数器以获取练习、示例等。)
我希望存在类似以下的东西,以便我可以创建一个新的#callout计数器。但我找不到这方面的基础设施:
The first definition is @callout-1.
:::{.callout-note}
## Definition {#callout-1}
This should be Definition 1.1.
:::
It is followed by the first example, @callout-2
:::{.callout-tip}
## Example {#callout-2}
This should be Example 1.2.
:::
Run Code Online (Sandbox Code Playgroud)
因为这不起作用,所以quarto将其呈现为:
但我正在寻找的是这样的结果:
我一直在寻找一种类似的解决方法,它允许我定义联合编号的环境组(针对 html 和 pdf),而无需额外的修改。我将我的解决方案放在扩展中。它暂时只支持 \ref 的交叉引用,也许它在 quarto 1.4 中就已经过时了?您可以从 yaml 修改每种环境类型的外观/颜色。
filters:
- custom-numbered-blocks
custom-numbered-blocks:
groups:
thmgroup:
boxstyle: foldbox.simple
collapse: false
classes:
Example:
group: thmgroup
Definition:
group: thmgroup
colors: [cce7b1, 86b754]
Run Code Online (Sandbox Code Playgroud)
然后
# First Section
The first definition is Definition \ref{mydef}
::: {.Definition #mydef}
This should be Definition \ref{mydef}
:::
It is followed by the first example, Example \ref{myexpl}
::: {.Example #myexpl}
### an example for Definition \ref{mydef}
This should be Example \ref{myexpl}
:::
Run Code Online (Sandbox Code Playgroud)
以 html 形式呈现
或 PDF 格式
要更改框的整体外观,您当前需要修改 css / tex 文件。
扩展在这里: https: //github.com/ute/custom-numbered-blocks