create a role (font color) in sphinx that works with `make latexpdf`

前端 未结 1 1262
孤独总比滥情好
孤独总比滥情好 2020-12-20 05:35

I\'m used to write Rest documents while I never used LaTex.

What I would like to do is create some font color roles that I can add inline the text (e.g. :re

相关标签:
1条回答
  • 2020-12-20 06:26

    Just add:

    1. 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 %}
      
    2. a 'source/_static/custom.css' file with

      @import url("default.css");
      
      .red {
        color: red;
      }
      

    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
    

    The global tree:

    test-sphinx
    ├── Makefile
    ├── build
    └── source
        ├── _static
        │   └── custom.css
        ├── _templates
        │   └── layout.html
        ├── conf.py
        └── index.rst
    

    An index.rst example:

    TS test!
    ========
    
    .. role:: red
    
    This is :red:`just` a test …
    

    Hope this help,

    Antoine

    0 讨论(0)
提交回复
热议问题