解决readthedocs生成中文pdf问题

参考链接:

https://github.com/JuliaCN/julia_zh_cn/blob/master/conf.py

https://github.com/zh-google-styleguide/zh-google-styleguide

一、配置方法

在conf.py中加入以下内容即可:

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#'preamble': '',
'preamble': r'''
\hypersetup{unicode=true}
\usepackage{CJKutf8}
\DeclareUnicodeCharacter{00A0}{\nobreakspace}
\DeclareUnicodeCharacter{2203}{\ensuremath{\exists}}
\DeclareUnicodeCharacter{2200}{\ensuremath{\forall}}
\DeclareUnicodeCharacter{2286}{\ensuremath{\subseteq}}
\DeclareUnicodeCharacter{2713}{x}
\DeclareUnicodeCharacter{27FA}{\ensuremath{\Longleftrightarrow}}
\DeclareUnicodeCharacter{221A}{\ensuremath{\sqrt{}}}
\DeclareUnicodeCharacter{221B}{\ensuremath{\sqrt[3]{}}}
\DeclareUnicodeCharacter{2295}{\ensuremath{\oplus}}
\DeclareUnicodeCharacter{2297}{\ensuremath{\otimes}}
\begin{CJK}{UTF8}{gbsn}
\AtEndDocument{\end{CJK}}
''',
}

下载链接:

conf

CJK是中日韩统一表意文字(CJK Unified Ideographs),使用这种字体在Adobe PDF上预览时有点儿模糊,但是其它PDF阅读器没有问题,打印也没有问题,因此这个问题忽略。

四、其它

调节字体参考:

https://www.cnblogs.com/dezheng/p/3874434.html (用CTEX集成的MiKTeX可以测试通,但sphinx-doc没有成功过)

分享到:更多 ()