使用sphinx/miktex生成在Windows中显示UTF8日语(CJK)文本的pdf文件

发布于 2024-07-17 00:33:18 字数 2424 浏览 9 评论 0原文

我有 ReSt (UTF8) 格式的文档,并且使用 sphinx 生成 HTML 和 Latex 文件。 (html 转换没有问题)

然后我想将生成的乳胶文件转换为 PDF。 目前我正在使用 MiKTeX 2.7 的 pdflatex.exe 命令来执行此转换。 (转换不带日语字符的源文件可以正确生成预期的 pdf)

使用 MiKTeX 包管理器我安装了 cjk 相关包:cjk-fonts、miktex-cjkutils-bin-2.7 和 cjk。

为了进行调试,我使用以下示例:

\documentclass{article}

\usepackage{CJK}

\begin{document}

\begin{CJK}{UTF8}{song}

\noindent Hello World!

\noindent Καλημέρα κόσμε
\noindent こんにちは 世界

\end{CJK}

\end{document}

在此文件上运行 pdflatex.exe 会产生以下输出:

pdflatex jutf8.tex jutf8.pdf
This is pdfTeX, Version 3.1415926-1.40.8-beta-20080627 (MiKTeX 2.7)
entering extended mode
(jutf8.tex
LaTeX2e <2005/12/01>
Babel <v3.8j> and hyphenation patterns for english, dumylang, nohyphenation, ge
rman, ngerman, german-x-2008-06-18, ngerman-x-2008-06-18, french, loaded.

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...

l.2
     サソ\documentclass{article}
?
("C:\Program Files\MiKTeX 2.7\tex\latex\base\article.cls"
Document Class: article 2005/09/16 v1.4f Standard LaTeX document class
("C:\Program Files\MiKTeX 2.7\tex\latex\base\size10.clo")
Overfull \hbox (20.0pt too wide) in paragraph at lines 2--284
[]
[1{D:/Profiles/All Users/Application Data/MiKTeX/2.7/pdftex/config/pdftex.map}]
) ("C:\Program Files\MiKTeX 2.7\tex\latex\cjk\CJK.sty"
("C:\Program Files\MiKTeX 2.7\tex\latex\cjk\mule\MULEenc.sty")
("C:\Program Files\MiKTeX 2.7\tex\latex\cjk\CJK.enc")) (jutf8.aux)
("C:\Program Files\MiKTeX 2.7\tex\latex\cjk\UTF8\UTF8.bdg")
("C:\Program Files\MiKTeX 2.7\tex\latex\cjk\UTF8\UTF8.enc")
("C:\Program Files\MiKTeX 2.7\tex\latex\cjk\UTF8\UTF8.chr")
("C:\Program Files\MiKTeX 2.7\tex\latex\cjk\UTF8\c70song.fd")Running makemf...
makemf: The cyberb source file could not be found.
Running hbf2gf...

hbf2gf (CJK ver. 4.7.0)

Couldn't find `cyberb.cfg'
maketfm: No creation rule for font cyberb03.

! Font C70/song/m/n/10/03=cyberb03 at 10.0pt not loadable: Metric (TFM) file no
t found.
<to be read again>
                   relax
l.12 \noindent ホ
                 ホアホサホキホシホュマ∃ア ホコマ狐πシホオ

How can I get Japanese to displayproperly in the result pdf using MiKTeX/pdflatex.exe?

I have documentation in ReSt (UTF8) and I'm using sphinx to generate HTML and latex files.
(No issues with html conversion)

I then want to convert the resulting latex file to PDf. Currently I'm using MiKTeX
2.7's pdflatex.exe command to perfom this conversion. (Converting a source file without Japanese characters produces the expected pdf correctly)

Using the MiKTeX Package Manager I've installed the cjk related packages: cjk-fonts, miktex-cjkutils-bin-2.7, and cjk.

To debug I'm using the following sample:

\documentclass{article}

\usepackage{CJK}

\begin{document}

\begin{CJK}{UTF8}{song}

\noindent Hello World!

\noindent Καλημέρα κόσμε
\noindent こんにちは 世界

\end{CJK}

\end{document}

Running pdflatex.exe on this file produces the following output:

pdflatex jutf8.tex jutf8.pdf
This is pdfTeX, Version 3.1415926-1.40.8-beta-20080627 (MiKTeX 2.7)
entering extended mode
(jutf8.tex
LaTeX2e <2005/12/01>
Babel <v3.8j> and hyphenation patterns for english, dumylang, nohyphenation, ge
rman, ngerman, german-x-2008-06-18, ngerman-x-2008-06-18, french, loaded.

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...

l.2
     サソ\documentclass{article}
?
("C:\Program Files\MiKTeX 2.7\tex\latex\base\article.cls"
Document Class: article 2005/09/16 v1.4f Standard LaTeX document class
("C:\Program Files\MiKTeX 2.7\tex\latex\base\size10.clo")
Overfull \hbox (20.0pt too wide) in paragraph at lines 2--284
[]
[1{D:/Profiles/All Users/Application Data/MiKTeX/2.7/pdftex/config/pdftex.map}]
) ("C:\Program Files\MiKTeX 2.7\tex\latex\cjk\CJK.sty"
("C:\Program Files\MiKTeX 2.7\tex\latex\cjk\mule\MULEenc.sty")
("C:\Program Files\MiKTeX 2.7\tex\latex\cjk\CJK.enc")) (jutf8.aux)
("C:\Program Files\MiKTeX 2.7\tex\latex\cjk\UTF8\UTF8.bdg")
("C:\Program Files\MiKTeX 2.7\tex\latex\cjk\UTF8\UTF8.enc")
("C:\Program Files\MiKTeX 2.7\tex\latex\cjk\UTF8\UTF8.chr")
("C:\Program Files\MiKTeX 2.7\tex\latex\cjk\UTF8\c70song.fd")Running makemf...
makemf: The cyberb source file could not be found.
Running hbf2gf...

hbf2gf (CJK ver. 4.7.0)

Couldn't find `cyberb.cfg'
maketfm: No creation rule for font cyberb03.

! Font C70/song/m/n/10/03=cyberb03 at 10.0pt not loadable: Metric (TFM) file no
t found.
<to be read again>
                   relax
l.12 \noindent ホ
                 ホアホサホキホシホュマ∃ア ホコマ狐πシホオ

How can I get Japanese to display properly in the resulting pdf using MiKTeX/pdflatex.exe?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北座城市 2024-07-24 00:33:19

我会使用 xelatex(自 2.7 起在 MikTeX 中可用)而不是 pdflatex 和 OpenType Kanji 字体。 文件 text.tex 包含

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Sazanami Gothic}

\begin{document}
こんにちは 世界
\end{document}

将“xelatex 文本”编译为 PDF,该文本采用 Sazanami Gothic 字体。

I would use xelatex (available in MikTeX since 2.7) instead of pdflatex and an OpenType Kanji font. The file text.tex consisting of

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Sazanami Gothic}

\begin{document}
こんにちは 世界
\end{document}

compiles with "xelatex text" to a PDF with this text in Sazanami Gothic font.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文