我正在尝试在 OSX 中将 Jupyter 笔记本转换为 PDF。我遇到了各种错误,这些错误都归结于升级 tlmgr
(base) mona@goku:~/Downloads/HW2_solutions$ ls /Library/TeX/texbin/tlmgr
lrwxr-xr-x 1 mona wheel 41 Mar 20 2019 /Library/TeX/texbin/tlmgr -> ../../texmf-dist/scripts/texlive/tlmgr.pl
(base) mona@goku:~/Downloads/HW2_solutions$ tlmgr update --self --all
/Library/TeX/texbin/tlmgr: open tlpdb(https://mirrors.rit.edu/CTAN/systems/texlive/tlnet/tlpkg/texlive.tlpdb) failed: No such file or directory at /usr/local/texlive/2018basic/tlpkg/TeXLive/TLPDB.pm line 362.
例如:
$ sudo tlmgr install adjustbox
Password:
/Library/TeX/texbin/tlmgr: open tlpdb(https://mirrors.rit.edu/CTAN/systems/texlive/tlnet/tlpkg/texlive.tlpdb) failed: No such file or directory at /usr/local/texlive/2018basic/tlpkg/TeXLive/TLPDB.pm line 362.
(base) mona@goku:~/Downloads/HW2_solutions$ sudo tlmgr install collectbox
tlmgr: Remote repository is newer than local (2018 < 2020)
Cross release updates are only supported with
update-tlmgr-latest(.sh/.exe) --update
Please see https://tug.org/texlive/upgrade.html for details.
这是我获得的 PDF 转换完整日志:
(base) mona@goku:~/Downloads/HW2_solutions$ jupyter nbconvert HW2_solutions.ipynb --to pdf
[NbConvertApp] Converting notebook HW2_solutions.ipynb to pdf
[NbConvertApp] Support files will be in HW2_solutions_files/
[NbConvertApp] Making directory HW2_solutions_files
[NbConvertApp] Making directory HW2_solutions_files
[NbConvertApp] Making directory HW2_solutions_files
[NbConvertApp] Making directory HW2_solutions_files
[NbConvertApp] Making directory HW2_solutions_files
[NbConvertApp] Making directory HW2_solutions_files
[NbConvertApp] Making directory HW2_solutions_files
[NbConvertApp] Making directory HW2_solutions_files
[NbConvertApp] Writing 84900 bytes to notebook.tex
[NbConvertApp] Building PDF
[NbConvertApp] Running xelatex 3 times: ['xelatex', 'notebook.tex']
[NbConvertApp] CRITICAL | xelatex failed: ['xelatex', 'notebook.tex']
This is XeTeX, Version 3.14159265-2.6-0.99999 (TeX Live 2018) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
(./notebook.tex
LaTeX2e <2018-04-01> patch level 2
Babel <3.18> and hyphenation patterns for 22 language(s) loaded.
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/base/size11.clo))
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/base/fontenc.sty
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/base/t1enc.def)
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/lm/t1lmr.fd))
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/psnfss/mathpazo.sty)
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/graphics-def/xetex.def)))
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/caption/caption.sty
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/caption/caption3.sty))
! LaTeX Error: File `adjustbox.sty' not found.
Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)
Enter file name:
! Emergency stop.
<read *>
l.42 \usepackage
{xcolor} % Allow colors to be defined^^M
No pages of output.
Transcript written on notebook.log.
Traceback (most recent call last):
File "/Users/mona/anaconda3/bin/jupyter-nbconvert", line 11, in <module>
sys.exit(main())
File "/Users/mona/anaconda3/lib/python3.6/site-packages/jupyter_core/application.py", line 266, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "/Users/mona/anaconda3/lib/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance
app.start()
File "/Users/mona/anaconda3/lib/python3.6/site-packages/nbconvert/nbconvertapp.py", line 325, in start
self.convert_notebooks()
File "/Users/mona/anaconda3/lib/python3.6/site-packages/nbconvert/nbconvertapp.py", line 493, in convert_notebooks
self.convert_single_notebook(notebook_filename)
File "/Users/mona/anaconda3/lib/python3.6/site-packages/nbconvert/nbconvertapp.py", line 464, in convert_single_notebook
output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer)
File "/Users/mona/anaconda3/lib/python3.6/site-packages/nbconvert/nbconvertapp.py", line 393, in export_single_notebook
output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
File "/Users/mona/anaconda3/lib/python3.6/site-packages/nbconvert/exporters/exporter.py", line 174, in from_filename
return self.from_file(f, resources=resources, **kw)
File "/Users/mona/anaconda3/lib/python3.6/site-packages/nbconvert/exporters/exporter.py", line 192, in from_file
return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
File "/Users/mona/anaconda3/lib/python3.6/site-packages/nbconvert/exporters/pdf.py", line 183, in from_notebook_node
raise LatexFailed('\n'.join(self._captured_output))
nbconvert.exporters.pdf.LatexFailed: PDF creating failed, captured latex output:
This is XeTeX, Version 3.14159265-2.6-0.99999 (TeX Live 2018) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
(./notebook.tex
LaTeX2e <2018-04-01> patch level 2
Babel <3.18> and hyphenation patterns for 22 language(s) loaded.
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/base/size11.clo))
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/base/fontenc.sty
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/base/t1enc.def)
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/lm/t1lmr.fd))
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/psnfss/mathpazo.sty)
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/graphics-def/xetex.def)))
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/caption/caption.sty
(/usr/local/texlive/2018basic/texmf-dist/tex/latex/caption/caption3.sty))
! LaTeX Error: File `adjustbox.sty' not found.
Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)
Enter file name:
! Emergency stop.
<read *>
l.42 \usepackage
{xcolor} % Allow colors to be defined^^M
No pages of output.
Transcript written on notebook.log.
我的 tlmgr 版本是:
$ tlmgr --version
tlmgr revision 47303 (2018-04-05 19:52:22 +0200)
tlmgr using installation: /usr/local/texlive/2018basic
TeX Live (http://tug.org/texlive) version 2018
遵循这里的答案应该会有所帮助,但我不知道将 tlmgr 从 2018 版本升级到 2020 版本的正确方法是什么:
https://github.com/ipython/ipython/issues/8814#issuecomment-146967331
sudo tlmgr install adjustbox
sudo tlmgr install collectbox
sudo tlmgr install ucs
答案1
下载了 mac tex 2020 版本,所有错误都消失了
http://tug.org/mactex/mactex-download.html
$ jupyter nbconvert HW2_solutions.ipynb --to pdf
创造了HW2_solutions.pdf