希望你一切都好。 我正在使用 Quartro 和 RStudio 来开发文档。 我的问题是,我如何才能创建一个类似于定理的本机功能的可参考假设(参见此处。
我尝试使用 .lua 文件,但没有成功。
local hypothesis_counter = 1
local hypothesis_label = "Hypothesis"
function Div(div)
if div.classes[1] == "hypothesis" then
local title = div.content[1].text
local description = div.content[2].text -- Extract description text
-- Construct the single-line content
local content = pandoc.Strong(hypothesis_label .. " " .. hypothesis_counter .. ": ")
content:insert(pandoc.Space())
content:insert(pandoc.Span(title))
content:insert(pandoc.Space())
content:insert(pandoc.Span(description))
-- Replace the div content with the single-line version
div.content = {content}
hypothesis_counter = hypothesis_counter + 1
end
return div
end
如果我没看错你的问题,这可以使用 Quarto 的自定义交叉引用语法轻松完成。阅读该链接以了解有关此功能的更多详细信息。例如 PDF:
---
format: pdf
crossref:
custom:
- key: hyp
kind: float
reference-prefix: Hypothesis
latex-env: hypothesis # This is required if you are using PDF format
---
This is some text prior to our custom cross-reference.
::: {#hyp-test}
## My Research Question
I hypothesize that A will cause B
:::
This is some text after the cross-reference, see @hyp-test above
产生以下文件: