squirrel2300

导航

jupyter notebook 目录配置、导出 tex 和 pdf 及中文支持

环境:macbook pro, mactex, jupyter notebook, brew

安装pandoc从而支持格式转换为tex:

brew install pandoc

修改tex article 模板,添加中文支持:

find / -name 'article.tplx' 2>/dev/null | xargs vi
# like .../nbconvert/templates/latex/article.tplx
# 或者分两条命令运行

修改Latex Article头部为:

%===============================================================================
% Latex Article
%===============================================================================
((* block docclass *))
\documentclass[11pt,adobefonts,fancyhdr,hyperref,UTF8]{article}
\usepackage{fontspec, xunicode, xltxtra}
\usepackage{ctex}    %中文支持
\setCJKmainfont{苹方-简}    %中文字体
((* endblock docclass *))

 (notebook标题似乎仍然不支持中文)

然后在jupyter notebook中直接下载为 pdf via LaTex即可自动得到pdf文件。或者下载为 latex(.tex) 再用 texshop -> xlatex 编译 亦可。

 

PS1: mark down 新手指南

PS2:jupyter notebook 设置默认目录方法

关闭notebook, 然后运行:

jupyter notebook --generate-config

# 生成config 文件, like /Users/xxx/.jupyter/jupyter_notebook_config.py

修改jupyter_notebook_config.py文件中 c.NotebookApp.notebook_dir 配置行:

## 用于笔记本和内核的目录。
c.NotebookApp.notebook_dir = '/Users/xxx/Projects/jupyter_workspace'

重启notebook即可

 

posted on 2018-11-08 10:40  squirrel2300  阅读(767)  评论(0编辑  收藏  举报