任务
我正在使用quarto编写一本在线书籍,并需要模拟已出版书籍的环境和计数器。后者使用了五个自定义框架环境(示例、练习、备注、定理、定义)和一个连接计数器(在本章中)。
我正在考虑使用现成的标注块来实现这些功能,因为默认情况下它们的样式非常好。但是,我没有成功地为这些标注块创建一个自定义计数器,这样我就可以从文本中交叉引用。是否有办法这样做?
(备注:我还试图通过通过quarto__提供的标准amsthm环境来实现这一点,参见https://stackoverflow.com/questions/73288264/shared-counter-in-quarto-for-exercises-examples-etc。)
演示
我本来希望有这样的东西存在,这样我就可以创建一个新的#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.
:::因为它的工作方式与quarto呈现如下所示的不同:

但我要找的是这样的结果:

发布于 2022-08-10 05:40:04
我唯一能做到的方法就是在标注中添加一个ID
::: {#callout-1 .callout-note}
## Definition {#callout-1}
This should be Definition 1.1.
:::然后在你的标记中手动调用:
Please refer to the [note 1](#callout-1)发布于 2022-08-10 10:49:38
通过将这个答案扩展到与此问题相关的其他问题,您可以参考标注块中的示例或练习,如
# Introduction
The first example is @exm-1.
::: {#exm-1}
This should be Example 1.1.
:::
It is followed by the first exercise, [Exercise @exm-2]
::: {#exm-2 .custom}
This should be Exercise 1.2.
:::
:::: {.callout-note}
::: {#exm-3}
This should be Example 1.3
:::
::::
:::: {.callout-tip}
::: {#exm-4 .custom}
This should be Exercise 1.4
:::
::::
Please refer to the @exm-3
Please refer to the [Exercise @exm-4]并在yaml _quarto.yaml项目中添加这两行
_quarto.yaml
callout-appearance: simple
callout-icon: false呈现的输出类似于,

再次注意,当您希望将示例环境呈现为练习时,请使用.custom 类,以便javascript代码 https://stackoverflow.com/a/73304425/10858321 将应用.。
此外,您还可以编写javascript代码,以同样的方式处理Definition标记。
https://stackoverflow.com/questions/73288564
复制相似问题