attribute: Phillie Casablanca

creating pdfs with Japnaese text using sphinx/pdflatex

This describes the process for preparing a setup on windows that can create PDF containing Japanese from sphinx output *.tex file.

Installation Steps

1. Create C:\w32tex directory

2. Create C:\w32tex\archivedpackages directory

3. Download "" from

4. Unzip "" into C:\w32tex

5. Download ALL files from the "最小インストール"(Minimal Install) and "標準インストール" (Standard install) lists and place them in C:\w32tex\archivedpackages

6. In addition download the following packages from the "フルインストール" (Full Install) list
- ums.tar.gz
- omegaj-w32.tar.gz
- ttf2pt1-w32.tar.bz2
- utf.tar.gz -- not sure if it's needed
- uptex-w32.tar.bz2 -- not sure if it's needed

7. Download and install ghostscript
1. Check the "Use Windows TrueType fonts for Chinese, Japanese and Korean" option and Install into C:\w32tex\gs

8. Download and install IPA fonts from
1. Drag and drop the *.ttf files found in the archive to the Windows/Fonts directory.
- this will install the fonts on the pc

9. Run the following command:

texinst757.exe C:\w32tex\archivedpackages

NOTE: This will take some time

10. Add the following to your system path:

- C:\w32tex\bin
- C:\w32tex\gs\gs8.63\bin
- C:\w32tex\gs\gs8.63\lib

11. Download, unzip and copy the titlesec folder to C:\w32tex\share\texmf\latex\

12. Run the following command (You may need to restart your console in order to take the new path settings into effect)
- This command will search and update fonts/styles (*i think*) that were added in step 11.



Converting Sphinx *.tex output to PDF

Now that you have w32tex installed, you still need to adjust some of your process in order to create a pdf properly.
Note: I'm using sphinx 0.6.1

1. In your add/uncomment the latex_elements and update to look like this:

latex_elements = {
'preamble': '\usepackage{ums}\input jpdftextounicode\pdfgentounicode=1',
'inputenc': '',
'fontenc': '',
'fontpkg': '',

2. Build your *.tex file using sphinx.
- My source files are utf8, and I believe sphinx outputs the *.tex to utf8.

3. Convert the output text to cp932 encoding
- Ideally, topdftex.exe/pdflatex.exe support utf8, but I haven't figured this out, so this is currently a workaround step

import codecs
import shutil
utf8_f ="sphinx_output.tex", "rb", "utf8")
cp932_f ='sphinx_output.cp932.tex', 'wb', 'cp923')

4. Run topdftex.exe on the converted output, renaming to the orignal *.tex name.

topdftex.exe sphinx_output.cp932.tex sphinx_output.tex

5. Run pdflatex.exe on the final output, sphinx_output.tex.

It was quite a struggle to get this far, I hope this helps others.

monkut // May 9, 2010 // 9:40 p.m.