[Tex/LaTex] Include Sphinx-generated documentation in master file

includesphinx

I'm currently working on a project (for university) that will be documented with LaTeX. About one third of the documentation will be about a python module that I've written.

I'm looking for a clean way to include the documentation generated by Sphinx into my main document. I think it would be possible to fiddle with the generated doc (remove preamble, move required \usepackage-commands in my main file, shift all headings down one level, etc.) and then include it, but I really hope that there is a better way.

I don't think that using Sphinx for the whole document would be a good idea since I'm not that confident in using it for more than code documentation.

Any hints are really appreciated!

Best Answer

It took me some time to figure this out, but as I just wanted to do the exact same thing, here you go 9 months later:

  1. Copy sphinx.sty to your main projects folder
  2. Add the following packages to your main file preamble:

    \usepackage{standalone}
    \usepackage{sphinx}
    
  3. Include your sphinx documentation like this:

    \part*{Appendix}
    \phantomsection
    \addcontentsline{toc}{part}{Appendix}
    \appendix
    \def\maketitle{}
    \def\tableofcontents{}
    \input{../project_name/doc/_build/latex/project_name}
    

This adds a nice, unnumbered part to the TOC and gives all the documentation sections letters as section numbering. It works for me with a completely untouched sphinx LaTeX output.