TextMate 中的 LaTeX 编译有时会抛出解析错误。其他人也遇到过同样的问题,但据我所知,目前还没有找到解决办法(请参阅https://stackoverflow.com/questions/74837558/pb-latex-compilation-with-textmate-under-os-ventura-13例如)。此错误与 LaTeX 无关:使用终端可以很好地编译该文档。
现在,我确实进行了一些调查,似乎罪魁祸首可能是重音字符、连字符和\usepackage[T1]{fontenc}
(我认为在使用重音字符时正确连字符是强制性的......)
这是一个 MWE,当不使用该包时,排版很好fontenc
,但使用时会失败。
\documentclass{article}
\usepackage[french]{babel}
\usepackage[T1]{fontenc} % If this line is commented, everything goes smoothly
\begin{document}
\begin{minipage}[t]{3cm} % A narrow minipage to force some hyphenation
éèàéééééééù éèàéééééééù some text with accented characters
\end{minipage}
\end{document}
错误:
Traceback (most recent call last):
File "/Users/johndoe/Library/Application Support/TextMate/Managed/Bundles/LaTeX.tmbundle/Support/bin/texmate.py", line 1054, in status = run_latex(command, filename, cache_filename, verbose)
File "/Users/johndoe/Library/Application Support/TextMate/Managed/Bundles/LaTeX.tmbundle/Support/bin/texmate.py", line 228, in run_latex fatal, errors, warnings = lp.parse_stream()
File "/Users/johndoe/Library/Application Support/TextMate/Managed/Bundles/LaTeX.tmbundle/Support/lib/Python/parsing.py", line 611, in parse_stream return super(LaTexParser, self).parse_stream()
File "/Users/johndoe/Library/Application Support/TextMate/Managed/Bundles/LaTeX.tmbundle/Support/lib/Python/parsing.py", line 195, in parse_stream line = self.get_rewrapped_line()
File "/Users/johndoe/Library/Application Support/TextMate/Managed/Bundles/LaTeX.tmbundle/Support/lib/Python/parsing.py", line 140, in get_rewrapped_line line = to_utf8(self.input_stream.readline())
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/codecs.py", line 322, in decode (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 77: invalid continuation byte
唉,我不知道该如何进一步调查。任何关于为什么会发生这种情况的想法都非常感谢!
PS 我使用的是 MacOS 12.6.3、带有最新软件包的 TextMate 2.0.23 和 TeXLive 2022(也是最新的)。
答案1
如果有人来到这里:这个问题已经解决了(见https://github.com/textmate/latex.tmbundle/issues/198)。