2

When running sphinx-build -b latex ... Sphinx writes a *.tex file into some output directory. The name of that *.tex file seems to somehow be derived from the project title set in conf.py.

I'd like to integrate the Sphinx Latex generation into my build system. For the dependency management I need to know the exact name of the generated *.tex file.

Is there any way to determine the name of the generated file without hard-coding that name into the build system? Or is there a way to set this name manually (without changing the project variable)?

mzjn
  • 48,958
  • 13
  • 128
  • 248
levzettelin
  • 2,600
  • 19
  • 32
  • You can use `ls`, `find` or `glob` (or your build system's OS equivalent) to find that file – DeepSpace Feb 26 '21 at 22:42
  • But that's only after the build has already run. I need to know it before, during the configure phase (CMake). Also, there may be multiple `*.tex` files in the output directory. – levzettelin Feb 26 '21 at 22:48
  • 1
    You can use the `latex_documents` configuration variable to set the name of the *.tex file: https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-latex_documents – mzjn Mar 01 '21 at 17:02

1 Answers1

2

As suggested by mzjn and explained in the Sphinx docs, one can set the name of the *.tex and *.pdf files via the latex_documents option in conf.py.

The canonical use case is probably to add the following at the end of conf.py.

#...
latex_documents = [('index', 'doc.tex', project, author, 'manual')]

This eventually produces a file doc.pdf.

levzettelin
  • 2,600
  • 19
  • 32
  • 1
    For `rst2pdf` it's similar: `pdf_documents = [("index", "outfilename", "title", author)]` – xjcl Aug 18 '21 at 21:10