我想将现有的.tex文件中的betacode转换为普通的希腊字母。
例如:我想要替换:
\ {BCODE LO / GOS}简单:
位蠈纬慰蟼等等所有其他字形。幸运的是……
尝试 python -V 在shell提示符下。你的代码是python 2代码,所以你将是一个python 2版本。
python -V
如果您不需要复杂的环境(并且您不需要解决此问题),那么最直接的方法就是去 python.org 。别忘了你需要python 2。
一般来说,它将如下:
python beta2unicode.py myfile.tex-file
并捕获输出:
python beta2unicode.py myfile.tex-file > myfile.not-tex-file
几乎。您将需要替换脚本末尾的代码,该代码以与此相同的方式启动,具有以下代码:
import sys t = beta2unicodeTrie() import re BCODE = re.compile(r'\\bcode{[^}]*}') for line in open(sys.argv[1]): matches = BCODE.search(line) for match in BCODE.findall(line): bcode = match[7:-1] a, b = t.convert(bcode.upper()) if b: raise IOError("failed conversion '%s' in '%s'" % (b, line)) converted = a.encode("utf-8") line = line.replace(match, converted) print(line.rstrip())
\documentclass[12pt]{scrbook} \usepackage[polutonikogreek, ngerman]{babel} \usepackage[ngerman]{betababel} \usepackage{fontspec} %\defaultfontfeatures{Ligatures=TeX} %\newfontfeature{Microtype}{protrusion=default;expansion=default;} \begin{document} 位峤刮澄肯僜n\end{document}