-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Guide to build PDF for non-ASCII language #5453
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
Build PDF format for non-ASCII languages | ||
======================================== | ||
|
||
|
||
.. warning:: | ||
|
||
To be able to follow this guide and build PDF with this method, | ||
you need to ask to enable ``USE_PDF_LATEXMK`` :doc:`feature flag </guides/feature-flags>` in your project. | ||
Please, `open an issue`_ in our repository asking for this and wait for one of the core team to enable it. | ||
|
||
.. _open an issue: https://github.com/rtfd/readthedocs.org/issues/new | ||
|
||
|
||
Sphinx comes with support for different `LaTeX engines`_ that support non-ASCII languages, | ||
like Japanese or Chinese, for example. | ||
By default Sphinx uses ``pdflatex``, | ||
which does not have good support for Unicode characters and may make the PDF builder to fail on these languages. | ||
|
||
.. _LaTeX engines: http://www.sphinx-doc.org/en/master/usage/configuration.html#confval-latex_engine | ||
|
||
In case you want to build your documentation in PDF format you need to configure Sphinx properly, | ||
so Read the Docs can execute the proper commands depending on these settings. | ||
There are `several settings that can be defined`_ (all the ones starting with ``latex_``), | ||
to modify Sphinx and Read the Docs behavior to make your documentation to build properly. | ||
|
||
A good first try would be to use only ``latex_engine = 'xelatex'`` in your ``conf.py``, | ||
if your docs are not written in Chinese or Japanese. | ||
This is because your build could be failing just because of an Unicode error | ||
(which ``xelatex`` has better support for them than the default ``pdflatex``) | ||
|
||
.. _several settings that can be defined: http://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-latex-output | ||
|
||
When Read the Docs detects that your documentation is in Chinese or Japanese it automatically adds some defaults for you. | ||
|
||
For *Chinese* projects, it appends to your ``conf.py`` these configurations: | ||
|
||
.. code-block:: python | ||
|
||
latex_engine = 'xelatex' | ||
latex_use_xindy = False | ||
latex_elements = { | ||
'preamble': '\\usepackage[UTF8]{ctex}\n', | ||
} | ||
|
||
And for *Japanese* projects: | ||
|
||
.. code-block:: python | ||
|
||
latex_engine = 'platex' | ||
latex_use_xindy = False | ||
|
||
.. tip:: | ||
|
||
You can always override these configurations if you define them by yourself in your ``conf.py`` file. | ||
|
||
.. note:: | ||
|
||
``xindy`` is currently not supported by Read the Docs, | ||
but we plan to support it in the near future. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Although this might be obvious to experienced folks, it is not clear that settings should be added to the project's
conf.py
file. I'd suggest inserting a sentence: