gpt4 book ai didi

python - sphinx:通过 raw::latex 包含 .tex 文件

转载 作者:太空宇宙 更新时间:2023-11-03 15:53:31 30 4
gpt4 key购买 nike

我想在 sphinx 中包含 latex 文档。 sphinx html 构建不包括使用 .. raw::latex 指令链接的 latex 文件。我有

这是我的目录结构

docs/
source/
importlatex.rst
index.rst

build/
tex/
texfile.tex

index.rst 看起来像

Welcome to documentation!
=========================

Contents:

.. toctree::
:maxdepth: 2

icnludelatex
and-other-stuff

icnludelatex.rst 看起来像:

Include Latex
=============

.. raw:: latex
:file: ../tex/texfile.tex

this reference给出包含 html 的示例

.. raw:: html
:file: inclusion.html

为什么会这样?

最佳答案

当您使用 raw 指令时,该 block 仅由关联的编写器 解释。例如,如果您生成 LaTeX,.. raw::latex 可以工作,但它对 HTML 是不可见的。

您需要的是 LaTeX 的解析器,但在快速搜索中,我只找到了 markdown ( recommonmark ) 和 jupyter notebook ( nbsphinx ) 的解析器。

也许,一个快速而肮脏的解决方案是使用 pandoc 将您的 latex 文档转换为 rst(您可能会丢失一些格式化文本)。

pandoc -s texfile.tex -o texfile.rst

然后在 icnludelatex.rst 中使用 include 指令。

.. include:: texfile.rst

关于python - sphinx:通过 raw::latex 包含 .tex 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45064321/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com