python-sphinx - Sphinx Admonition 的自定义(多字)标题
问题描述
我使用 Sphinx 发布课程。我想创建一个自定义警告,其标题由几个单词组成(例如“历史注释”)。我想出了一个.admonition-title:after
在我的 custom.css 文件中使用的肮脏技巧:
.admonition-historical {
border: solid 1px;
border-color: rgb(153,102,153);
}
.rst-content .admonition-historical .admonition-title {
background: #AD85AD;
}
.rst-content .admonition-historical {
background: #EDE5ED
}
.rst-content .admonition-historical .admonition-title:before {
content: " ";
}
.rst-content .admonition-historical .admonition-title:after {
content: " notes";
}
这在 HTML 文档中可以正常工作,但在 LaTeX 版本中却不行,它仅显示为“历史”。
用复杂的多词标题定义警告的正确方法是什么,在 HTML 和 LaTeX 中都能很好地呈现?
解决方案
我不确定我是否正确理解了你的问题。但是,有一个admonition
指令允许在其参数中设置标题:
.. admonition:: This is generic admonition title
Generic admonition are rarely used but has one important benefit over
specific ones: author may define admonition title in directive argument.
Specific admonitions gets its type as title (danger has danger as title
etc.).
推荐阅读
- sql - 枢轴相同的值
- yii2 - 如何在 mpdf 库中使用 writeCell
- amazon-web-services - Terraform:如何提供使用一个资源块创建的资源的属性?
- automation - 在 linux/debian 上进行非交互式 Steam 安装(如何自动接受 EULA?)
- swift - 根据泛型类型实现功能的泛型类
- java - “抛出 ArithmeticException”是否只是方法定义中的装饰?
- pine-script - 如何在行的顶部显示标签?
- ios - 如何居中 TabBarItem - Swift
- javascript - Laravel 5:附加输入文本取决于所选选项 vue js
- python - 使用python将数据文件拆分为单独的文件