当我尝试使用 xelatex --8bit 和 pythontex 编译以下最小示例时发生错误。
\documentclass[a4paper]{book}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\usepackage{pythontex}
%%%%%%%%%%%%
\begin{document}
\section{Première section}
\py{1+10}
\end{document}
执行 pythontex 后,我收到以下消息。
This is PythonTeX 0.16
Traceback (most recent call last):
File "/Library/TeX/texbin/pythontex", line 62, in <module>
pythontex.main()
File "/usr/local/texlive/2018/texmf-dist/scripts/pythontex/pythontex2.py", line 2712, in main
parse_code_write_scripts(data, temp_data, engine_dict)
File "/usr/local/texlive/2018/texmf-dist/scripts/pythontex/pythontex2.py", line 1099, in parse_code_write_scripts
interactive)
File "/usr/local/texlive/2018/texmf-dist/scripts/pythontex/pythontex_engines.py", line 456, in get_script
workingdir_full = os.path.join(os.getcwd(), workingdir).replace('\\', '/')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py", line 73, in join
path += '/' + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xcc in position 47: ordinal not in range(128)
我该如何修复它?对于排版,我在 MacOS 上使用 TeXPad 和以下脚本:
#!/bin/bash
# Texpad build (.tpbuild) file to use PythonTeX within Texpad
# NB this is to demonstrate pythontex only, it would need alterations to support bibliographies, indices, etc.
xelatex -8bit -synctex=1 "$TEXPAD_ROOTFILE"
pythontex --runall=true "$TEXPAD_ROOTFILE_NO_EXT"
bibtex "$TEXPAD_ROOTFILE_NO_EXT"
xelatex -8bit "$TEXPAD_ROOTFILE"
xelatex -8bit -synctex=1 "$TEXPAD_ROOTFILE"
或者简单地
xelatex -8bit namefile
pythontex --runall=true namefile
bibtex namefile
xelatex -8bit namefile
xelatex -8bit -synctex=1 namefile
在贝壳上。