在 Markdown 中,可以像这样创建内联代码链接
[`dict.update`](https://docs.python.org/3/library/stdtypes.html#dict.update)
Run Code Online (Sandbox Code Playgroud)
渲染效果如下dict.update。如何在 reStructuredText / Sphinx 中获得类似的行为?我尝试(1)使用转换器,但它永远不会产生类似的结果(2)嵌套外部链接`link <link>`_和内联代码块:code:`dict.update`,但这也不起作用。
我想在 R Markdown 文档中的参考书目之后添加表格和数字。但是,默认情况下,R Markdown 文档将始终将参考书目添加到报告的末尾。
有没有一种简单的方法可以在引用后向文档添加内容?
一个以前的答案表明,就是把附录中的R在降价后书目的方式。此附录是一个单独的文件,并after_body通过 YAML 标头添加到文档中。我尝试了 2 种不同的可能解决方案,但都没有奏效。
results = "hide"将它们隐藏在主文件中。这个想法是创建 2 个单独的 PDF 并合并它们。不幸的是,当数字被隐藏时,参考也变成了?? .bookdown:pdf_document2.R文件创建的,并使用include_graphics().我在交叉引用自定义指令生成的部分时遇到问题。
这是指令:
from docutils import nodes
from docutils.parsers import rst
class TestDirective(rst.Directive):
has_content = False
required_arguments = 1
option_spec = {}
def run(self):
my_arg = self.arguments[0]
target_node = nodes.target('', '', refid=nodes.make_id(my_arg))
section = nodes.section(
'',
nodes.title(text=my_arg),
ids=[nodes.make_id(my_arg)],
names=[nodes.fully_normalize_name(my_arg)])
return [target_node, section]
def setup(app):
app.add_directive('mytest', TestDirective)
Run Code Online (Sandbox Code Playgroud)
这是它的使用方法:
=============
Test document
=============
.. mytest:: section1
Section 1 content.
.. _section2:
section2
========
Section 2 content.
Run Code Online (Sandbox Code Playgroud)
现在,以下仅适用于section2:
Here are links to :ref:`section1` and :ref:`section2`.
Run Code Online (Sandbox Code Playgroud)
该链接仅正确生成section2,我收到以下错误:
test.rst:19: WARNING: undefined label: …Run Code Online (Sandbox Code Playgroud) 参考链接如何在OCaml中工作?
例如,假设我有3个模块声明为
A.mlB.mlC.ml其中
A需要B和CB 需求 A我该如何进行编译?
由于订单是相关的,ocamlc或者ocamlopt我如何修复B和之间的交叉参考A?
我想首先他们都汇编成.cmo用ocamlc -c,然后链接所有的人都在一起,但自从与交换参数将刚刚从一个模块移动到另一个问题没有成功.
具体错误是:
错误:链接A.cmo时出错:引用未定义的全局`B'
(或者反之,如果我交换了args的顺序)
我认为这是一个简单的问题,但我无法解决它...提前感谢
考虑两个模块(在同一文件夹中):
首先,person.py
from typing import List
from .pet import Pet
class Person:
def __init__(self, name: str):
self.name = name
self.pets = [] # type: List[Pet]
def adopt_a_pet(self, pet_name: str):
self.pets.append(Pet(pet_name))
Run Code Online (Sandbox Code Playgroud)
然后是pet.py
from .person import Person
class Pet:
def __init__(self, name: str, owner: Person):
self.name = name
self.owner = owner
Run Code Online (Sandbox Code Playgroud)
由于循环依赖,上述代码无法正常工作。您会得到一个错误:
ImportError: cannot import name 'Person'
Run Code Online (Sandbox Code Playgroud)
使其工作的一些方法:
例如:
class Pet:
def __init__(self, name: str, owner):
Run Code Online (Sandbox Code Playgroud)
到目前为止,我列出的所有选项中都有一些缺点。
还有另一种方法吗?一个让我能够
或者:是否有充分的理由改而采用我已经列出的解决方案之一?
python annotations circular-dependency type-hinting cross-reference
我正在使用四开本创建一份长 PDF 报告。我想包括两种格式的交叉引用:
正如3.1 节中讨论的
正如我的精彩部分中所讨论的。
可以这样实现:
---
format:
pdf:
number-sections: true
---
# Why Stack Overflow is so great {#sec-stack}
I can use style 1, the section number, with the explicit ID, e.g. as seen in @sec-stack.
I can use style 2, the section title, with a link [Why Stack Overflow is so great].
I can also custom text with [Custom text before the link][Why Stack Overflow is so great].
Run Code Online (Sandbox Code Playgroud)
这会产生所需的输出:
问题是该文件正在由几位作者重新起草。如果章节标题从Why Stack …
我的 .net 解决方案中有三个项目。
主项目和两个类库项目。
我发现我需要交叉引用类库项目。
我可以这样做吗?安全吗还是有一些注意事项?
试图在 Rmarkdown 中找到一种方法来交叉引用自动编号和/或通过其命名的章节来做类似的事情
"As I explained hundred pages ago in \ref{ch:Chapter_Label}....."
Run Code Online (Sandbox Code Playgroud)
然后生成的生成的 pdf 文档具有以下内容:
"As I explained hundred pages ago in Chapter 3....."
Run Code Online (Sandbox Code Playgroud)
或者
"As I explained hundred pages ago in <Chapter Name> ....."
Run Code Online (Sandbox Code Playgroud)
我在想一些机制,比如:
\chapter{My_Title} \label{ch:1}
Run Code Online (Sandbox Code Playgroud)
然后在我使用的文本中的任何地方,\ref{ch:1}我都会得到文本嵌入的“My_Title”或“Chapter 1”(或它获得的任何自动编号)。
Rmarkdown 似乎无法使用 hyperref 包,或者我遗漏了一些东西。
有人可以帮助我吗?
感谢bookdownYihui Xie提供的非常有用的软件包,数字的交叉引用非常有效。并且可以参考这个问题中描述的数字
但是,在用 R 为科学论文撰写出版物时,我必须将几组数字分开。第一组是进入出版物的数字,第二组是补充数字。
我想有一个单独的计数器用于补充数字。目前有没有办法在bookdown包装中做到这一点?
所以基本上我喜欢
\@ref(fig:figure1) # evaluates to Fig. 1
\@ref(fig:figure2) # evaluates to Fig. 2
\@ref(figS:supplementary-figure1) #evaluates to Fig. S1.
Run Code Online (Sandbox Code Playgroud)
附注。对我来说最重要的输出是bookdown::word_document2
最小工作示例:
---
title: "MWD"
output: bookdown::word_document2
---
# Results
This text refers to Fig. \@ref(fig:fig1main).
We also want to refere here to Fig. \@ref(fig:fig2main).
In some cases we also need supplementary data. Please see Suppl. Fig. S\@ref(fig:fig1supp).
Please note that the 'S' before the reference should optimally NOT …Run Code Online (Sandbox Code Playgroud) 我想交叉引用我包含在降价语法中的图像。
我希望能够将此图像交叉引用为\@ref(fig:caption-with-spaces).
我正在使用bookdown::pdf_document2.
这可能吗?
cross-reference ×10
r-markdown ×5
bookdown ×3
python ×3
r ×3
knitr ×2
latex ×2
pandoc ×2
.net ×1
annotations ×1
docutils ×1
linker ×1
module ×1
ocaml ×1
quarto ×1
recursion ×1
type-hinting ×1