Skip to content

Commit 7874751

Browse files
committed
Guide to build PDF for non-ASCII language
1 parent 54397a0 commit 7874751

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
Build PDF format for non-ASCII languages
2+
========================================
3+
4+
Sphinx comes with support for different `LaTeX engines`_ that support non-ASCII languages,
5+
like Japanese or Chinese, for example.
6+
By default Sphinx uses ``pdflatex``,
7+
which does not have good support for Unicode characters and may make the PDF builder to fail on these languages.
8+
9+
.. _LaTeX engines: http://www.sphinx-doc.org/en/master/usage/configuration.html#confval-latex_engine
10+
11+
In case you want to build your documentation in PDF format you need to configure Sphinx properly,
12+
so Read the Docs can execute the proper commands depending on these settings.
13+
There are `several settings that can be defined`_ (all the ones starting with ``latex_``),
14+
to modify Sphinx and Read the Docs behavior to make your documentation to build properly.
15+
16+
A good first try would be to use ``latex_engine = 'xelatex'`` only,
17+
if your docs are not written in Chinese or Japanese.
18+
This is because your build could be failing just because of an Unicode error
19+
(which ``xelatex`` has better support for them than the default ``pdflatex``)
20+
21+
.. _several settings that can be defined: http://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-latex-output
22+
23+
When Read the Docs detects that your documentation is on Chinese or Japanese it automatically adds some defaults for you.
24+
25+
For *Chinese* projects, it appends to your ``conf.py`` these configurations:
26+
27+
.. code-block:: python
28+
29+
latex_engine = 'xelatex'
30+
latex_use_xindy = False
31+
latex_elements = {
32+
'preamble': '\\usepackage[UTF8]{ctex}\n',
33+
}
34+
35+
And for *Japanese* projects:
36+
37+
.. code-block:: python
38+
39+
latex_engine = 'platex'
40+
latex_use_xindy = False
41+
42+
.. tip::
43+
44+
You can always override these configurations if you define them by yourself in your ``conf.py`` file.
45+
46+
.. note::
47+
48+
``xindy`` is currently not supported by Read the Docs,
49+
but we plan to support it in the near future.

0 commit comments

Comments
 (0)