T1 fontenc 和 latin1 日志文件导致的tinytex 警告

问题描述 投票:0回答:1

问题

我在一个文件上运行

tinytex::latexmk()
,其中包含 (a) UTF-8 编码、(b) T1 字体编码、(c) 包含重音字符的满水平框。这会创建一个采用 latin1 (ISO-8859-1) 编码的日志文件,导致来自
tinytex
的警告。

可重现的示例

tinytex::latexmk("tiny.tex")
## [1] "tiny.pdf"
## Warning messages:
## 1: In xfun::read_utf8(log) :
##   The file tiny.log is not encoded in UTF-8. These lines contain invalid UTF-8 characters: 51
## 2: In grep("^(LaTeX|Package [[:alnum:]]+) Warning:", x) :
##   unable to translate 'r/bx/n/10 vari-able di-cot<f3>mica\T1/cmr/m/n/10 . ' to a wide string
## 3: In grep("^(LaTeX|Package [[:alnum:]]+) Warning:", x) :
##   input string 51 is invalid

其中

tiny.tex
包含

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\begin{document}
\begin{itemize}
\item In this line we get an overfull hbox because the word \textbf{variable dicotómica}.
\end{itemize}
\end{document}

系统信息

R 4.3.1 在 Debian/GNU Linux(测试)系统上使用

tinytex
0.46 和
xfun
0.40 以及 TeXLive 2023.20230613-3,运行 en_US.UTF-8 语言环境。 TinyTeX 发行版未安装,即 R 包
tinytex
调用系统 TeXLive。不过,我们在 Windows 系统上也看到了同样的问题

解决方法

我可以通过不使用 T1 字体编码来避免这个问题,即通过省略或注释

tiny.tex
中的第二行。然后使用 OT1 字体编码,关于溢出 hbox 的日志消息采用 ASCII 格式。

问题

我可以做些什么来获取 UTF-8 格式的日志消息吗?或者

tinytex
必须处理它(例如,通过读取字节然后使用
iconv()
)?

r utf-8 latex iso-8859-1 tinytex
1个回答
0
投票

(部分答案基于 Sebastian Meyer 的列表外反馈:)

日志消息实际上并不是 latin1 编码的。相反,它包含用于排版的字符的表示形式,可以由文本编辑器和类似工具将其解释为 latin1。在 pdfLaTeX 中这是无法避免的(仅在 LuaLaTeX 或 XeLaTeX 中)。

详细信息在 Enrico Gregorio 的回答和 David Carlisle 的进一步评论中解释。在此讨论中,建议将日志文件读取为字节(而不是 UTF-8 编码文件)。

© www.soinside.com 2019 - 2024. All rights reserved.