You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Quarto PDF中渲染普什图文报错hyphen-pashto不存在,求解决办法

在Quarto PDF渲染普什图文时解决hyphen-pashto缺失问题

问题背景

在R环境中用Quarto渲染含普什图文的PDF时,因官方TeX仓库无hyphen-pashto包,触发以下报错:

installing hyphen-pashto (1 of 1)
ERROR: [non-error-thrown] tlmgr returned a non zero status code
tlmgr install: package hyphen-pashto not present in repository.
tlmgr: action install returned an error; continuing.
tlmgr: An error has occurred. See above messages. Exiting.

使用的原代码如下:

---
title: "Pashto text"
format: 
  pdf:
    toc: true
    number-sections: false
    colorlinks: true
    pdf-engine: lualatex
include-in-header:
  text: |
    \usepackage{fontspec}
    \usepackage[bidi=basic]{babel}
    \babelprovide[import=ps,mapdigits]{pashto}
    \babelfont[pashto]{rm}[Renderer=HarfBuzz]{Amiri}
---

```{r setup, echo=FALSE, include=FALSE}
cat("\\selectlanguage{pashto} دا پښتو متن دی")
cat("\\n")
## 可行解决办法
- **阻止自动安装缺失包**:在PDF格式配置中添加`tlmgr-install: false`,禁止Quarto调用tlmgr自动安装不存在的`hyphen-pashto`,避免渲染中断。
- **禁用普什图断字功能**:在`\babelprovide`命令中加入`nohyphenation`参数,让babel不对普什图文执行断字操作,彻底消除对hyphen包的依赖。

修改后的完整配置代码:
```yaml
---
title: "Pashto text"
format: 
  pdf:
    toc: true
    number-sections: false
    colorlinks: true
    pdf-engine: lualatex
    tlmgr-install: false
include-in-header:
  text: |
    \usepackage{fontspec}
    \usepackage[bidi=basic]{babel}
    \babelprovide[import=ps,mapdigits,nohyphenation]{pashto}
    \babelfont[pashto]{rm}[Renderer=HarfBuzz]{Amiri}
---

```{r setup, echo=FALSE, include=FALSE}
cat("\\selectlanguage{pashto} دا پښتو متن دی")
cat("\\n")
- **手动添加断字规则(进阶)**:若需要保留断字功能,可自行寻找普什图断字规则文件(如从开源语言项目获取),将其放置在LaTeX的`texmf`搜索目录下,再通过babel配置指定该规则文件。此方法需具备LaTeX基础配置经验,仅推荐有需求的用户尝试。

内容的提问来源于stack exchange,提问作者Gion Mors
相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 23:17:05