jupyter notebook导出含中文的pdf(LaTex安装和Pandoc、MiKTex安装)

发布于:2024-03-29 ⋅ 阅读:(149) ⋅ 点赞:(0)

用jupyter notebook导出pdf时,因为报错信息,需要用到Tex

nbconvert failed: xelatex not found on PATH, if you have not installed xelatex you may need to do so. Find further instructions at https://nbconvert.readthedocs.io/en/latest/install.html#installing-tex.

一 LaTex安装

1.TexLive下载安装

官网

直接git下载

git clone https://github.com/latex3/latex2e.git

或者 

清华大学开源软件镜像

双击.bat文件 

大概需要1-2小时,如果安装失败,重新进行安装

查看是否安装成功:

latex -v 

2.TeXstudio编辑器的安装

清华大学开源软件镜像站 

下载后,双击安装,安装路径选择默认最好!! 

3.安装验证

安装完成后,打开编辑器

搜索栏搜索“TeXstudio”(为了方便,快捷方式可以移到桌面)

1、新建一个空白文件

2. 编写一个简单的文档,编译并查看效果

\documentclass[UTF8]{article}

\begin{document}
	hello!
\end{document}

输入代码后,构建并查看 

3、保存

最后,请记住自己安装texlive和texstudio的路径!!!!

我的路径:

 C:/softwares/texlive/2024

C:\Program Files\texstudio

4.导出验证

重启jupyter notebook,再次导出pdf,成功!!!!!

pdf如下: 

如果还不行的话,尝试配置路径,把C:\softwares\texlive\2024\bin\windows路径加入path中

5.不显示中文处理

由上图可看出红色箭头指向的 # 号后面的中文没有显示出来

修改jupyter内置文件(以下是路径)

\documentclass[11pt]{ctexart}

修改前: 

修改后:

重启jupyter notebook后,导出,中文显示了

 更多pdf导出显示问题

二 如果上面的不行,再用下面的方法

1安装Pandoc

Pandoc官网下载地址: https://pandoc.org/installing.html

git下载

Release pandoc 3.1.6.2 · jgm/pandoc · GitHub

正常安装即可 

gitcode的镜像也有:https://gitcode.net/mirrors/jgm/pandoc/-/releases/3.1.6.1?spm=1033.2243.3001.5876

2安装MiKTex

如果导出pdf通过LaTex,还需要下载MiKTex: https://miktex.org/download

 正常安装即可!

记得重启jupyter notebook!!!!!

补充: 更多LaTex使用


网站公告

今日签到

点亮在社区的每一天
去签到