Commits

Akihiro Uchida  committed 1bf51ba

support pTeX and dvipdfmx with sphinx.sty

  • Participants
  • Parent commits 65e4c29

Comments (0)

Files changed (2)

File sphinx/texinputs/sphinx.sty

 %\renewcommand{\paperwidth}{8.5in}   % typical squarish manual
 %\renewcommand{\paperwidth}{7in}     % O'Reilly ``Programmming Python''
 
+% use pdfoutput for pTeX and dvipdfmx
+\ifx\kanjiskip\undefined\else
+  \ifx\Gin@driver{dvipdfmx.def}\undefined\else
+    \newcount\pdfoutput\pdfoutput=0
+  \fi
+\fi
+
 % For graphicx, check if we are compiling under latex or pdflatex.
 \ifx\pdftexversion\undefined
   \usepackage{graphicx}
   \addcontentsline{toc}{chapter}{\bibname}
 }
 
+% to make pdf with correct encoded bookmarks in Japanese
+% this should precede the hyperref package
+\ifx\kanjiskip\undefined\else
+  \usepackage{atbegshi}
+  \ifx\ucs\undefined
+    \ifnum 42146=\euc"A4A2
+      \AtBeginShipoutFirst{\special{pdf:tounicode EUC-UCS2}}
+    \else
+      \AtBeginShipoutFirst{\special{pdf:tounicode 90ms-RKSJ-UCS2}}
+    \fi
+  \else
+    \AtBeginShipoutFirst{\special{pdf:tounicode UTF8-UCS2}}
+  \fi
+\fi
+
 % Include hyperref last.
 \RequirePackage[colorlinks,breaklinks,
                 linkcolor=InnerLinkColor,filecolor=OuterLinkColor,

File sphinx/writers/latex.py

 
             # pTeX (Japanese TeX) for support
             if builder.config.language == 'ja':
-                self.elements['classoptions'] = ',dvipdfm'
-                # found elements of babel, but this should be above sphinx.sty.
-                # because pTeX (Japanese TeX) cannot handle this count.
-                self.elements['babel'] = r'\newcount\pdfoutput\pdfoutput=0'
-                # to make the pdf with correct encoded hyperref bookmarks
-                self.elements['preamble'] += \
-                    r'\AtBeginDvi{\special{pdf:tounicode EUC-UCS2}}'
+                # use dvipdfmx as default class option in Japanese
+                self.elements['classoptions'] = ',dvipdfmx'
+                # disable babel which has not publishing quality in Japanese
+                self.elements['babel'] = ''
         else:
             self.elements['classoptions'] += ',english'
         # allow the user to override them all