简体   繁体   English

是否可以将 LaTeX 包含到 Sphinx 中?

[英]Is it possible to include LaTeX into Sphinx?

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. Sphinx Titlepage 可以在 conf.py 中使用“latex_elements”和“preamble”指令进行自定义,但我找不到将普通乳胶源代码包含到 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?有没有办法在文档正文中包含 Latex-Code?

(I've define a latex-"newcommand" in the preamble in conf.py but dont know how to call it in sphinx) (我在 conf.py 的序言中定义了一个 latex-“newcommand”,但不知道如何在 sphinx 中调用它)

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::

     codehere

In conf.py you can define a new command like /newcommand{\newCom}{...} .conf.py ,您可以定义一个新命令,例如/newcommand{\newCom}{...}

In a sphinx text file this command can be referenced with:在 sphinx 文本文件中,可以使用以下命令引用此命令:

.. raw:: latex

        \newCom

Crucial was the newline after the ".. raw:: latex" command, it seems as if omitting that was the issue.关键是“.. raw:: latex”命令之后的换行符,似乎忽略了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM