只需要加入宏包
\usepackage[UTF8]{ctex}
$ cat _output.yaml
beamer_presentation:
theme: Warsaw
colortheme: dove
toc: true
keep_tex: false
latex_engine: xelatex
incremental: no
includes:
in_header: _header.tex
$ cat _header.tex
%\usepackage[fontset=windows,UTF8]{ctex}
\usepackage[UTF8]{ctex}
\logo{\includegraphics[height=0.09\textwidth]{logo/zhima.png}}
$ cat zhima20161124.Rmd
---
title: 题目
author: |
| 作者
| 单位
date: \today
---
……
sudo yum install perl-Digest-MD5
sudo mount -o loop texlive2016.iso /mnt
sudo ./install-tl
sudo umount /mnt
sudo vim /etc/bashrc
sudo vim /usr/lib64/R/etc/Renviron
tar -zxvf winfont.tgz
sudo mv usr/local/texlive/texmf-local/fonts/truetype /usr/local/texlive/texmf-local/fonts/
sudo fc-list
sudo texhash
$ls /usr/local/texlive/texmf-local/fonts/truetype/ -hl
total 61M
-rw-r--r-- 1 root root 11M Dec 16 19:55 simfang.ttf
lrwxrwxrwx 1 root root 11 Dec 16 19:57 SIMFANG.TTF -> simfang.ttf
-rw-r--r-- 1 root root 9.4M Dec 16 19:55 simhei.ttf
-rw-r--r-- 1 root root 12M Dec 16 19:55 simkai.ttf
lrwxrwxrwx 1 root root 10 Dec 16 19:57 SIMKAI.TTF -> simkai.ttf
-rw-r--r-- 1 root root 8.8M Dec 16 19:55 simli.ttf
-rw-r--r-- 1 root root 15M Dec 16 19:55 simsun.ttc
-rw-r--r-- 1 root root 6.4M Dec 16 19:55 simyou.ttf
ctex 修改 documentclass
\documentclass[UTF8, hyperref,fontset=windows]{ctexart}
或 增加引用ctex包
\usepackage[fontset=windows,UTF8]{ctex}
修改文件头 /usr/lib64/R/library/rmarkdown/rmd/latex/default.tex
\documentclass[...,$endfor$,hyperref,UTF8, fontset=windows]{ctexart}
%\documentclass[...,$endfor$]{$documentclass$}
或
cat slidy.Rmd
---
title: 题目
author: |
| 作者
| 单位
date: \today
fontfamily: ctex
fontfamilyoptions: fontset=windows,UTF8
---
或用yaml 模版,(注意,用xelatex 选项,不依赖系统)
$ cat _output.yaml
beamer_presentation:
theme: Warsaw
colortheme: dove
toc: true
keep_tex: false
latex_engine: xelatex
incremental: no
includes:
in_header: _header.tex
$ cat _header.tex
%\usepackage[fontset=windows,UTF8]{ctex}
\usepackage[UTF8]{ctex}
\logo{\includegraphics[height=0.09\textwidth]{logo/zhima.png}}
$ cat zhima20161124.Rmd
---
title: 题目
author: |
| 作者
| 单位
date: \today
---
……
修改模版文件 base.tplx
sed -i '/usepackage{graphicx}/a \\\\\usepackage[UTF8,fontset=windows]{ctex}' base.tplx
调用函数, 注意 用xelatex, pdflatex失败
import nbformat
from nbconvert.exporters import (HTMLExporter, PDFExporter)
from nbformat.v4 import new_markdown_cell
exporter = PDFExporter(latex_count=2, latex_command = [u"xelatex", u"{filename}"])
exporter.default_template_path = '/home/keke.zhaokk/.jupyter/nbconvert/templates/latex'
nb_json = nbformat.read("/home/yan.xi/public/test1.ipynb", as_version=4)
(body, resources) = exporter.from_notebook_node(nb_json)
系统文件路径
$#sudo vim /opt/anaconda3/lib/python3.4/site-packages/nbconvert/exporters/pdf.py
$# .../nbconvert/templates/latex/base.tplx
对于windows,或者texlive早期版本,只修改模版就好。
sudo fc-list
sudo texhash
#sudo mktexlsr
matplot画图的中文问题
sudo mkdir -p /usr/share/fonts/chinese/TrueType/
sudo cp /usr/local/texlive/texmf-local/fonts/truetype/simsun.ttc /usr/share/fonts/chinese/TrueType/
sudo cp /usr/local/texlive/texmf-local/fonts/truetype/simhei.ttf /usr/share/fonts/chinese/TrueType/
sudo fc-cache /usr/share/fonts/chinese/TrueType
fc-list
sudo vim /opt/anaconda3/lib/python3.5/site-packages/matplotlib/mpl-data/matplotlibrc
把字体挪到 系统目录, 执行texhash 即可
sudo mv truetype /usr/local/texlive/texmf-local/fonts/
sudo texhash
手机扫一扫
移动阅读更方便
你可能感兴趣的文章