-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Maybe use xelatex instead of pdflatex by default #4159
Comments
@jfbu could you give us comments for this please? I can't determine it's better or not. I don't know which is good successor of PDFLatex, LuaTeX and XeTeX. And Also don't know they are enough stable or not for usage of Sphinx. Of course, I will agree to change default latex engine if either one is enough stable. |
I will make general remarks.
Making xelatex default will modify looks of all Sphinx produced PDFs, because xelatex should be used with OpenType fonts. It can be used with traditional TeX fonts, but then hyphenation mechanism of TeX is broken in some languages. Recently the LaTeX team has modified behaviour of LaTeX so that by default if used with So making This looks like quite some work at Sphinx side... I think first step is to move Sphinx towards supporting multi-lingual documents. Because making |
One last pros and cons:
|
That's a lot to consider and I'm no latex expert. I just noticed that the current default (pdflatex/platex) put me in a hard situation when building english, french, and japanese:
So I just can't have a successful build with It took me some time to find the "right combination", which looks in fact really simple, just replace pdflatex with xelatex as a default engine but keep the "default to platex for japanese if default engine is used". In one hand I may be short sighted as I tested a single project, in the other hand the Python documentation is huge (230k lines of rst). |
+1 to xelatex I can confidently say that most Chinese LaTeX users prefer xelatex to pdflatex nowadays, because xelatex has MUCH better support for opentype fonts, thus Chinese uses find it WAY MORE easier to display Chinese characters in the generated pdf. The same technology applies to Japanese and Korean characters too (we often refer their fonts together as CJKfonts). @jfbu In my understanding, sphinx-doc maintains its default template of pdf, thus something like “front issue” should not be a problem (to users)? @JulienPalard switching from pdflatex to xelatex for JP doc is not THAT trivial. At least you should set \setCJKmainfont , otherwise JP characters are not expected to be displayed correctly. Still, it’s kind of easy for simple cases, see https://tex.stackexchange.com/questions/139081/cjk-blank-output-for-japanese-characters |
Some more helpful info here:
|
There is no notion of seamless experience in LaTeX regarding Unicode, although xelatex and lualatex have considerably improved the situation. Already, Sphinx does the minimal right thing regarding xelatex which is not to use inputenc nor fontenc. With a recent LaTeX this means it will automatically use the Latin Modern OpenType font which has good coverage of European (in the large sense) languages.
It has no coverage for Chinese or Hebrew for example. This means Sphinx user for a project in these languages must customize LaTeX preamble to appropriately use The way this is done is system dependent regarding fonts which are provided with TeX itself (and on Mac OS X one must use different methods depending on whether the OpenType font is a system/user font or in the TeX tree). Even the minimal Sphinx set-up for xelatex contains elements which are not satisfactory: the coverage of French language by polyglossia is far more restricted than what the babel-frenchb module provides: with polyglossia there is no conformity regarding footnotes and lists with the French typographical rules. Besides, latex-babel is now (after some years of stagnation) actively maintained and being developed in direction of xelatex/lualatex support. As a result it is not clear if polyglossia will remain preferable to babel in future. Regarding French as I said it is not. Sphinx French user of xelatex is now well advised to modify
Making For example, similarly as we have specific coverage of japanese [1]_, we can provide specific coverage of Chinese if consensus emerges on how to best set-it up with XeLaTeX and this must be done Windows, Mac OS X, Unixen... Contributions are most welcome ! .. [1] which as mentioned already in this thread goes currently via And, stressing again, this does not solve problems one may encounter with stray Unicode characters ! |
Here is basic test of Hebrew with \documentclass[hebrew]{article}
\usepackage{polyglossia}
\setmainlanguage{hebrew}
\begin{document}
מבוא
\end{document} Produces errors:
Attempting to try Sphinx on minimal Hebrew document with xelatex leads to plenty of problems:
in conf.py:
and the one of interest to this thread:
(as above) This confirms Sphinx-doc user will have to know a minimum of LaTeX macros ( (we at Sphinx should probably take care of loading |
Note:
I don't know this is really needed. I've never seen such request. So it's okay to support only one language per project at once. (edit) oh, I understand #4159 requires it... |
@tk0miya in the case of CPython docs (which is big...), for example French translation is only at It could make sense (not only for PDF perhaps, but for PDF it is important due to hyphenation which depends on language) to have multi-lingual. Currently only portions of CPython's (I am using |
Ah, I understand. Surely, it is mixture of English and French. |
@tk0miya But this is done by Docutils already. Consider this test file Welcome to FOO's documentation!
===============================
Hello
.. class:: language-fr
Bonjour
.. class:: language-de
Guten Tag
Again English. and then \documentclass[a4paper]{article}
% generated by Docutils <http://docutils.sourceforge.net/>
\usepackage{cmap} % fix search and cut-and-paste in Acrobat
\usepackage{ifthen}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french,ngerman,english]{babel}
% Prevent side-effects if French hyphenation patterns are not loaded:
\frenchbsetup{StandardLayout}
\AtBeginDocument{\selectlanguage{english}\noextrasfrench}
[lines cut]
\begin{document}
\maketitle
Hello
\foreignlanguage{french}{Bonjour}
\foreignlanguage{ngerman}{Guten Tag}
Again English.
\end{document} On further experiment in case of multiple paragraphs each one is given as argument to On the other hand Sphinx Hello
\begin{fulllineitems}
\pysigline{\sphinxbfcode{language-fr}}
Bonjour
Un autre paragraphe
\end{fulllineitems}
\begin{fulllineitems}
\pysigline{\sphinxbfcode{language-de}}
Guten Tag
\end{fulllineitems}
Again English. Possibly related to #4010 |
HTML output from <p>Hello</p>
<p lang="fr">Bonjour</p>
<p lang="fr">Un autre paragraphe</p>
<p lang="de">Guten Tag</p>
<p>Again English.</p> |
@jfbu: In Sphinx, the |
@mitya57: thanks for the tip, which does work indeed for html target, producing same |
Sphinx 2.0 will use GNU FreeFont with (edit: and make suitable choice of fonts for Chinese with |
i use hindi, and same problem will be faced with using any indian language script (Hindi, Nepali, Tamil, Telugu, Pubjabi, Marathi, Gujarati, ...).
that's 'cz xelatex outputs in pdf, and modifying pdf is what takes time. to save on that, Ref (abridged by me, original at: latexmk-pdf):
Unabridged verbatim:
|
There is in our docs this tip:
This It is probably time in 2017 we do this unconditionally. |
Subject: I built the cpython documentation in french and japanese, and found it non-trivial to find the right set of options.
Problem
Given that:
Є
in https://docs.python.org/3.7/whatsnew/3.7.html#optimizations)We could expect to find non-ascii characters everywhere, which are badly supported by pdflatex, even by using utf8x which come with another set of issues.
Proposed solution
I finally found that xelatex handle very well unicode characters, but does not work well with japanese. And platex works well with japanese.
platex is already the default with the latex_engine is not explicitly configured, which is already nice, but there is no way to configure xelatex for all languages and platex for japanese (#4150).
It forces everyone to learn a lot about latex and PDF generation, and finally force them to use -D with external logic to switch between working engines like https://github.com/python/docsbuild-scripts/pull/34/files.
Also, the documentation is not very explicit about the usages of those engines (see #4149).
What I propose is to switch the default from
'pdflatex' if language != 'ja' else 'platex'
to'xelatex' if language != 'ja' else 'platex'
which is a combination that works without any other modification to build cpython documentation in english, french, and japanese.The text was updated successfully, but these errors were encountered: