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