I want to include latex doc in sphinx. sphinx html build does not include the latex file linked using .. raw:: latex
directive. I have
this is my dir structure
docs/
source/
importlatex.rst
index.rst
build/
tex/
texfile.tex
index.rst
looks like
Welcome to documentation!
=========================
Contents:
.. toctree::
:maxdepth: 2
icnludelatex
and-other-stuff
icnludelatex.rst
looks like:
Include Latex
=============
.. raw:: latex
:file: ../tex/texfile.tex
this reference gives example for including html
.. raw:: html
:file: inclusion.html
why is this happening?
When you use a raw
directive, the block is only interpreted by the writer associated. Example, .. raw:: latex
works if you generate LaTeX but it is invisible to HTML.
What you need is a parser for LaTeX, but in a fast search, I only find parsers for markdown (recommonmark) and jupyter notebook (nbsphinx).
Maybe, a quick and dirty solution is to convert your latex doc to rst using pandoc (you may lose some formatted text).
pandoc -s texfile.tex -o texfile.rst
and then use the include
directive in your icnludelatex.rst
.
.. include:: texfile.rst
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With