-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PDF builds should use Sphinx provided LaTeX Makefile which uses Latexmk (and possibly xindy) #4454
Comments
We aren't going to execute any pdfs builds through the Makefile, we avoid the Makefile completely. Is there a solution that doesn't require using the Makefile? |
For the majority of projects I expect the sequence
i.e. one additional
Sphinx LaTeX builder converts templates to project-adjusted Makefile and Latexmk config file. They include:
Regarding the Latexmk config file (for non-Japanese) only the And for Japanese documents (which use platex+dvipdfmx) there is also extra step of running In older times, Sphinx did pdflatex thrice (!), then makeindex, then pdflatex twice, so a total number of 5 (!) pdflatex runs. One can see this in old latex Makefile. Thus there is quite some logic incorporated
This logic means that when Sphinx user does himself PDF build, the workflow is substantially faster than formerly, because Latexmk will know to execute perhaps only one pdflatex run when latex sources have changed but PDF was already build earlier. (user does PDF builds may also execute All this to say that trying to extract a fix number of pdflatex/makeindex calls isn't really feasible, although for vast majority of projects I expect simply pdflatex (once) + makeindex + pdflatex (twice) is adequate. What is certain is that pdflatex + makeindex + pdflatex is inadequate, because the makeindex call creates new tex code which is executed on second pdflatex call and this tex code wants to add a new entry in table of contents, which always needs 2 passes in latex. And as already indicated the makeindex way will become with Sphinx 1.8 replaced by xindy way for non-English projects. Thus any hard-coded project independent code is bound to raise problems. |
For pdflatex engine, Sphinx 1.8 still uses makeindex per default even for non-English (non-Japanese) documents. But for xelatex/lualatex it will use xindy because makeindex is incompatible with UTF-8. |
Thanks for the detailed information! We might be calling on you more to help because I don't think any of us are well experienced with latex, and the need to perform multiple passes on PDF build seems like a silly latex design from the outside. A couple things:
|
At core level TeX page breaking algorithm never gets to see the document as a whole. It accumulates vertical material and it tests legitimate page breaking points when enough material has accumulated. It chooses the locally best one, ships out the built page, forgets about it and iterates. For achieving internal references such as a table of contents, the LaTeX developers (thirty years ago, circa) thus developed a multi-pass system. Fact of life ... I am not sure to understand what you mean about Makefile being error prone. The Makefile is constructed by Sphinx as part of the process of building LaTeX output. It is part of LaTeX builder output in a way. It takes into account the latex engine specified by user. Using xelatex to build PDFs works only is user project has specified the latex engine to be xelatex. If not, and if for example the language is German, then xelatex will fail producing correct PDF output, some letters used in German will be missing or words will not be correctly hyphenated, because xelatex does not work well with traditional TeX fonts, due to the fact that the LaTeX format for xelatex is not constructed the same way by the LaTeX team as for pdflatex. Xelatex is designed for using system (OpenType/TrueType) fonts, and the font configuration is not an external parameter but something which must be hard-coded in the LaTeX document itself, so it is a user configuration. It is impossible to say I will compile all those LaTeX documents with xelatex: the documents have to know they will get compiled with xelatex. |
That is not such a problem for 'manual' type project because the numbering is reset after the table of contents, but 'howto' documents will have that problem. |
As far I can remember, Makefile generation is optional, also for windows I think they generate a bat file, so maybe some users can be updating one file or another and not both. Users may don't have a makefile, etc. |
A user may indeed have possibly broken custom Makefile related to using but: via The idea here could be rather to force use the Sphinx generated Makefile. The issue is that it is a template which has variables depending on how user has configured LaTeX in the conf.py. However this will use Latexmk, which itself depends on configuration files (latexmkrc). This configuration file can also be overriden by user via Basically, you of course don't need this latex Makefile, as in case of pdflatex builds, it only issues
wow! (the initial bit is in case there is no I may now start looking very scary. To recap:
This will handle correctly Sphinx projects using I hope I did not get too scary before that conclusion... |
@stsewd, it's not. Using Makefile - the "official" way of post-processing latex output (to PDF or something else). There is no Sphinx option to turn this off. Either you have to re-implement all this functionality, or PDF output in the rtfd will be mostly useless feature, as it is now. Btw, using Makefile will also solve #1556. |
@jfbu thanks for your detailed explanation! I'd like to know if there is a way to not use the Makefile generated by Sphinx and support all the PDF builders ( Is it possible using |
@humitos Leaving aside the case of Japanese documents (
Notice that Xindy is default for xelatex/lualatex. They are broken without it for indices. Don't fiddle with the If using a Latexmk from January 2017 or newer (4.52b) you can add You may also consider |
I tried a little more today to build the Chinese version of requests with I was trying to do this, to see if we can start allowing some experimental testing with this under a Feature flag in production. Although, I don't want to enable anything like this unless we have a few projects tested and we know that this is working. @jfbu do you have in mind any project that I can use for testing this that "just builds" without doing anything strange/weird or any kind of customized modification? It would be good to have a couple of them for these different cases that we were mentioning: German, Chinese, Japanese, and other non-ASCII languages. |
New versions of Sphinx use `latexmk` to build the PDF files. This command uses a file called `latexmkrc` (or `latexmkjarc` for Japanese) which contains all the proper commands that needs to be ran depending on different Sphinx configurations. `latexmk` will take care by itself on the amount of phases that need to be ran without us worrying about it. Currently, this is not considering LATEXMKOPTS and XINDYOPTS environment variables configured by Sphinx. This feature is implemented under a Feature flag so we can test it easily without breaking other working projects. References: - #1556 - #4454 - #5405 - toppers/tecs-docs#7 - https://github.com/sphinx-doc/sphinx/blob/master/sphinx/texinputs/Makefile_t - https://www.sphinx-doc.org/en/master/usage/builders/index.html#sphinx.builders.latex.LaTeXBuilder
New versions of Sphinx use `latexmk` to build the PDF files. This command uses a file called `latexmkrc` (or `latexmkjarc` for Japanese) which contains all the proper commands that needs to be ran depending on different Sphinx configurations. `latexmk` will take care by itself on the amount of phases that need to be ran without us worrying about it. Currently, this is not considering LATEXMKOPTS and XINDYOPTS environment variables configured by Sphinx. This feature is implemented under a Feature flag so we can test it easily without breaking other working projects. References: - #1556 - #4454 - #5405 - toppers/tecs-docs#7 - https://github.com/sphinx-doc/sphinx/blob/master/sphinx/texinputs/Makefile_t - https://www.sphinx-doc.org/en/master/usage/builders/index.html#sphinx.builders.latex.LaTeXBuilder
New versions of Sphinx use `latexmk` to build the PDF files. This command uses a file called `latexmkrc` (or `latexmkjarc` for Japanese) which contains all the proper commands that needs to be ran depending on different Sphinx configurations. `latexmk` will take care by itself on the amount of phases that need to be ran without us worrying about it. Currently, this is not considering LATEXMKOPTS and XINDYOPTS environment variables configured by Sphinx. This feature is implemented under a Feature flag so we can test it easily without breaking other working projects. References: - #1556 - #4454 - #5405 - toppers/tecs-docs#7 - https://github.com/sphinx-doc/sphinx/blob/master/sphinx/texinputs/Makefile_t - https://www.sphinx-doc.org/en/master/usage/builders/index.html#sphinx.builders.latex.LaTeXBuilder
It seems PDF builds at RTD by default use something like this
i.e. they don't simply proceed via
make -C <buildir> all-pdf
which would use the Sphinx provided Makefile (there are ways to pass options to pdflatex if needed). The latter uses Latexmk which does automatically the correct number of pdflatex runs.This causes issue #2857, but may cause more issues starting with Sphinx 1.8.
Indeed at Sphinx 1.8, a new user configuration value
latex_use_xindy
is provided to support indexing of terms beyond English ascii letters. Only the Sphinx provided Makefile + Latexmk configuration file latexmkrc has the correct invocation ofxindy
which depends on the document language.If RTD used by default the Sphinx provided LaTeX Makefile, already for Sphinx 1.7.x, and certainly for Sphinx
>= 1.8
this would solve #2857 and support the newlatex_use_xindy
Sphinx option painlessly.Notice that with
latex_engine
set by user toxelatex
,xindy
usage will be default. Indeedmakeindex
is broken with UTF-8 index files. Withlualatex
such broken files causes a PDF build abort, and withxelatex
they appear to work, but by luck, and the index in PDF is ill-formed.The text was updated successfully, but these errors were encountered: