在 sphinx 中创建一个与“make latexpdf"一起使用的角色(字体颜色) [英] create a role (font color) in sphinx that works with `make latexpdf`
问题描述
我习惯写 Rest 文档,而我从来没有使用过 LaTex.
I'm used to write Rest documents while I never used LaTex.
我想做的是创建一些字体颜色角色,我可以添加内联文本(例如:red:this text is red
)html和latexpdf编译.
What I would like to do is create some font color roles that I can add inline the text (e.g. :red:this text is red
) that work both in html and in latexpdf compilation.
我发现了一个类似的问题这里,但我无法重现它.
I've found a similar question here, but I cannot reproduce it.
我认为 magic 将完成更改 conf.py
文件,但我不知道如何.
I think that the magic will be done changing the conf.py
file, but I didn't find out how.
另外,在latexpdf
编译过程中,在_build/latex
目录下,有一个sphinx.sty
文件,里面包含了很多用于定制最终pdf文件的东西.
Moreover, during the latexpdf
compilation, in the _build/latex
directory, there is a sphinx.sty
file that contains a lot of things for the customization of the final pdf file.
如果我想更改最终 pdf 文件的某些参数,我是否要编辑此文件,将其放在某处并告诉 sphinx 采用此样式文件?
If I want to change some parameter of the final pdf file, have I to edit this file, put it somewhere and tell sphinx to take this style file?
对不起所有这些东西,但我有点困惑..
Sorry for all these stuff, but I'm a little bit confused..
谢谢!
推荐答案
只需添加:
'source/_templates/layout.html' 文件,包含
a 'source/_templates/layout.html' file with
{% extends "!layout.html" %}
{% block extrahead %}
<link rel="stylesheet" type="text/css"
href="{{ pathto('_static/custom.css', 1) }}" />
{% endblock %}
'source/_static/custom.css' 文件,带有
a 'source/_static/custom.css' file with
@import url("default.css");
.red {
color: red;
}
您现在可以在您的 rst 文件中使用 :red: 角色.不要忘记 html 或 css 版本后的反勾号和干净的目标:
You can now use a :red: role in your rst files. Don't forget the back tick and the clean target after html or css editions:
A :red:`red`text
$> make clean html
全局树:
test-sphinx
├── Makefile
├── build
└── source
├── _static
│ └── custom.css
├── _templates
│ └── layout.html
├── conf.py
└── index.rst
一个 index.rst 示例:
An index.rst example:
TS test!
========
.. role:: red
This is :red:`just` a test …
希望对您有所帮助,
安东尼
这篇关于在 sphinx 中创建一个与“make latexpdf"一起使用的角色(字体颜色)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!