Sphinx 自动图像编号/标题?

发布于 2024-07-19 02:10:16 字数 451 浏览 9 评论 0原文

有没有办法使用 sphinx 自动生成图像/图形标题?

我目前有rest-sphinx 文件,我正在使用sphinx 将其转换为html 和(latex)pdf。

我想要一种简单的方法让用户在生成的 html/pdf 文件中引用特定图像。 例如,如果用户在电子邮件中引用文档,“在‘图像 65’中显示 XXX,但这对我不起作用”。

我尝试过使用 figure ,它似乎允许您将标题应用于图像,但这必须手动添加。 (由于某种原因,我在使用替换时遇到问题)。

有没有我忽略的rest-sphinx方法可以实现这一点? 或者,有没有办法修改/编辑 sphinx 的现有模板以添加此功能?

Is there a way to automatically generate an image/figure caption using sphinx?

I currently have rest-sphinx files I'm converting to html and (latex)pdf using sphinx.

I'd like an easy way for users to reference a specific image in the resulting html/pdf files.
For example, if a user is refering to the documentation in an email, "In 'Image 65' it says XXX, but this doesn't work for me".

I've tried using figure where it appears to allow you to apply a caption to an image, but this has to be manually added. (And I have problems getting it to work with substitution for some reason).

Is there a rest-sphinx method I'm overlooking that would achieve this?
Or, is there a way to modify/edit sphinx's existing templates to add this ability?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

山川志 2024-07-26 02:10:16

Sphinx 使用 Jinja 模板化的 reStructuredText。 不过,根据 Sphinx 文档,您还有其他模板选项

您应该能够使用 Jinja 的控制结构 在自定义模板中实现您想要的效果。

Sphinx consumes reStructuredText as templated by Jinja. According to the Sphinx documentation though, you have other templating options.

You should be able to use Jinja's control structures in a custom template to achieve the effect you're after.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文