【问题标题】:Is it possible to include LaTeX into Sphinx?Is it possible to include LaTeX into Sphinx?
【发布时间】:2022-12-28 03:55:26
【问题描述】:

The Sphinx Titlepage can be customized in conf.py with "latex_elements" and the "preamble" directive but i cant find a solution to include normal latex source code into sphinx. The reason is that i want to customize some pages of the document with latex.

Is there a way to include Latex-Code in the body of an document?

(I've define a latex-"newcommand" in the preamble in conf.py but dont know how to call it in sphinx)

【问题讨论】:

    标签: latex python-sphinx restructuredtext


    【解决方案1】:

    You can do it 2 ways:

    The first way is that you can define it when you use it:

    My raw code:
    .. raw:: latex
    
         code here
    

    The other way is that you can define it at the end of the file and use it:

    My raw code: |rawcode|
    
    .. |rawcode| raw:: latex
    
         codehere
    

    【讨论】:

      【解决方案2】:

      In conf.py you can define a new command like /newcommand{ ewCom}{...}.

      In a sphinx text file this command can be referenced with:

      .. raw:: latex
      
              
      ewCom
      

      Crucial was thenewlineafter the ".. raw:: latex" command, it seems as if omitting that was the issue.

      【讨论】:

      • A directive starts with two dots, a space, a directive name, two colons, at least one space, then the arguments which can be on multiple subsequent lines, then options oin the form of ":optionname: optionvalue" on separated lines, then an empty line, then the directive's content. Read the official specific here: docutils.sourceforge.io/docs/ref/rst/directives.html
      猜你喜欢
      • 2022-12-01
      • 2022-12-02
      • 2022-12-02
      • 2022-12-02
      • 2022-12-27
      • 2022-12-19
      • 2022-12-02
      • 2022-12-02
      • 2022-12-27
      相关资源
      最近更新 更多