Search code examples
python-sphinxxelatex

Can the XeLaTeX builder be used with Sphinx?


Although the end-problem that this would solve is a TeX one (installing a new font for PDF output), this particular solution that I'm looking for is a Sphinx issue. Sphinx uses standard LaTeX when making PDFs, which is fine so far, but I need to install a new font and have tried and failed. I understand this is a far easier process using XeLateX, so would like to know if there is an extension or some way to configure Sphinx to make it use the XeLaTeX builder instead.


Solution

  • I think this boils down to getting in some LaTeX instructions before sphinx starts its work.

    At the start of your index.rst, you can add a "raw" entry that's passed verbatim to latex:

    .. raw:: latex
    
       \setyournicefontorwhatever(beautiful.ttf)
    

    Does that help to get the correct font in? I'm using raw latex entries myself to remove the section numbers from part of my documentation (\setcounter{secnumdepth}{-1} in a similar "raw" entry).

    Also, the Sphinx documentation on build options has some things you can try. The most promising looks to be the documentclass item in the latex_documents setting.