-
Notifications
You must be signed in to change notification settings - Fork 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
Add default quickstart support for Chinese LaTex support. #3244
Conversation
Most common use of Chinese LaTeX is xelatex+ctex with encoding UTF-8, and there are many other possible configurations for different tasks. For example, another option is to use pdflatex+ctex with encoding GBK. Generally no one uses basic "latex" command to generate chinese pdfs as it is outdated, unmaintained and too complicated to configure.
I've considered adding this configuration to writers/latex.py. |
repair a bug in previous commit: default language set to '', avoiding issues when language is None
Thank you for proposal. Now sphinx also provides default settings to Japanese. I believe it would be nice if we can merge your settings into |
BTW, Is this change stable? |
before this change it is not possible to generate chinese pdf by default. There are some blogs talking about workarounds on sphinx chinese pdf generation, they alter the output tex file manually. Thank you for your reply, I'll check builders/latex.py recently, which I didn't read before. |
for chinese latex output, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I commented above, I prefer to provide the default settings in setup()
function in LaTeX builder.
I think conf.py
should be used for "customization". We should not add a default settings to the file.
So please update this PR based on #3251.
@@ -141,7 +141,13 @@ latex_documents = [ | |||
(master_doc, '{{ project_fn }}.tex', u'{{ project_doc_texescaped_str }}', | |||
u'{{ author_texescaped_str }}', 'manual'), | |||
] | |||
|
|||
{% if language|default('').split('_')[0] == 'zh' %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jinja2 raises TemplateSyntaxError in this line:
TemplateSyntaxError: expected token 'end of statement block', got '.'
https://travis-ci.org/sphinx-doc/sphinx/jobs/184147701#L2019
Does this really work correct in your environment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this runs correct in my environment, but I haven't touched tox before and I can not configure it to work correctly for now
I run this program successfully, on windows anaconda python3
# Leave it configurable here for user customization | ||
if language.split('_')[0] == 'zh': | ||
latex_engine = 'xelatex' | ||
latex_elements = {'usepackages':'\\usepackage{ctex}','polyglossia':''} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
usepackage
is an internal variable, so we can't say this always works fine.
It might be overwritten by any extensions. (It is used for `Sphinx.add_latex_package() API.)
How about this? I believe it might work fine.
latex_elements = {'polyglossia': '\\usepackage{ctex}'}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
base on this version, it does not work. Because it set 'multilingual' and 'babel' to empty string on 'ja' only.
So 'zh_*' would have a multilingual property and got an error on method "babel_renewcommand".
This method generate tex file lines like:
\addto\captionsenglish{\renewcommand{\figurename}{图 }}
This is not correct.
I believe after your refactor last weekend, it will be easier to find a place to add chinese support.
I'll check the latest version later, thanks.
LaTeX builder: Refactor the default settings generators (refs: #3244)
Now we start to discuss in new PR #3272. Thanks, |
Most common use of Chinese LaTeX is xelatex+ctex with encoding UTF-8, and there are many other possible configurations for different tasks.
For example, another option is to use pdflatex+ctex with encoding GBK.
Generally no one uses basic "latex" command to generate chinese pdfs as it is outdated, unmaintained and too complicated to configure.