[TIPS] Succeeded to make a PDF including CJK text by sphinx

334 views
Skip to first unread message

Hiroki Watanabe

unread,
Jan 13, 2014, 12:03:23 AM1/13/14
to sphinx...@googlegroups.com
Hello,

I succeeded to make a PDF including the following languages by sphinx,
on windows 7.

* Chinese
* Japanese
* Korean
* Thai
* German
* English

Please see attached for an example.

I don't know much about Tex so this may not be a correct way. But,
anyway, I did it. So I'll post this article to share my experience.

Prerequirements
===============
* Sphinx 1.2
* Tex Live 2013 (http://www.tug.org/texlive)
* Arial Unicode MS
* GNU Unifont in TrueType format (http://www.lgm.cl/trabajos/unifont/index.en.html)
* Windows 7

How to
======

1. Make a sphinx project by sphinx-quickstart

2. Add the followings to conf.py

latex_elements = {
   'inputenc': '',
   'utf8extra': '',
   'preamble': '''

\usepackage{fontspec}
\usepackage{xeCJK} % this is needed to support for wrapping CJK text
\setsansfont{Arial Unicode MS}
\setromanfont{Arial Unicode MS}
\setmonofont[ Path = ./fonts/ ]{unifont.ttf} % set path where you installed unifont.ttf
''',
}

3. Add CJK text to your sphinx documents and save them in UTF-8.

(Example text of simplified Chinese, Japanese, Korean, Thai, German and English)
* 北京首都国际机场 (Beijing Capital International Airport)
* 成田国際空港 (Narita International Airport)
* 인천국제공항 (Incheon International Airport)
* ท่าอากาศยานสุวรรณภูมิ (Suvarnabhumi International Airport)
* Flughafen München Franz Josef Strauß (Munich Airport)

4. Generate tex files and build it by xelatex

$ make latex
$ cd .\build\latex
$ xelatex *.tex
$ xelatex *.tex
(I don't know why, but to make toc in PDF, you have to execute xelatex twice)

5. Done

Please let me know if you have any idea to improve this method.

Best regards,


ExampleofCJKinPDF.pdf

Luc Saffre

unread,
Jan 16, 2014, 11:12:45 PM1/16/14
to sphinx...@googlegroups.com
Looks great!
Thanks for sharing this!

I found only a typo: in "Arial Unicode MS is a propotilal font", replace
"propotilal" by "proportional".

Luc
> --
> You received this message because you are subscribed to the Google
> Groups "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to sphinx-users...@googlegroups.com.
> To post to this group, send email to sphinx...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sphinx-users.
> For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages