admin管理员组文章数量:1393114
I am attempting to render text in Pashto in a Quarto pdf in r. Below my code:
---
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")
```
I get the following error:
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.
In my understanding, there is no hyphen-pashto package. Is there a workaround?
I am attempting to render text in Pashto in a Quarto pdf in r. Below my code:
---
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")
```
I get the following error:
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.
In my understanding, there is no hyphen-pashto package. Is there a workaround?
Share Improve this question asked Mar 13 at 13:26 Gion MorsGion Mors 3171 gold badge3 silver badges23 bronze badges 3- 1 Maybe try latex3.github.io/babel/guides/locale-pashto.html – samcarter_is_at_topanswers.xyz Commented Mar 13 at 13:41
- 1 Unfortunately, I get the following error: LaTeX Error: File `pashto.cls' not found. – Gion Mors Commented Mar 13 at 13:58
- pashto should be the class option, not the class – samcarter_is_at_topanswers.xyz Commented Mar 13 at 14:23
1 Answer
Reset to default 2You can use fontspec
and then create a new fontfamily pashtofont
with Script=Arabic. Amiri seems to be not available, which is why I took Arial. The cat-output can be parsed as LaTeX if you put results = 'asis'
. We then also have to use \\textdir TRT
, otherwise cat
will flip the arabic and this will change the meaning!
Option 1 (easy)
---
title: "Pashto text"
format:
pdf:
toc: true
number-sections: false
colorlinks: true
pdf-engine: lualatex
include-in-header:
text: |
\usepackage{fontspec}
\newfontfamily\pashtofont[Script=Arabic]{Arial}
---
```{r test, echo=FALSE, include=TRUE, results='asis'}
cat("\\pashtofont \\textdir TRT دا پښتو متن دی")
```
giving
Option 2 with custom 'Amiri' font
You can download Amiri-Regular.ttf and put it in the same directory as your quarto file. Then use the following as outlined here
---
title: "Pashto text"
format:
pdf:
toc: true
number-sections: false
colorlinks: true
pdf-engine: lualatex
include-in-header:
text: |
\usepackage[bidi=default, nil]{babel}
\usepackage{fontspec}
\newfontfamily\psfnt[Renderer={Harfbuzz}]{Amiri-Regular.ttf}
\DeclareTextFontCommand\pstxt{\psfnt}
---
```{r test, echo=FALSE, include=TRUE, results='asis'}
cat("\\textdir TRT \\pstxt{دا پښتو متن دی}")
```
Note:
tinytex::install_tinytex()
helps but will eventually still fail when used with babel and I tried lot's of things. This solution was given here and helped for the "tlmgr returned a non zero status code" error but not directly for this issue. How to reinstall tinytex. What you see here worked for me.
本文标签: rHow to render text in Pashto in a Quarto pdfStack Overflow
版权声明:本文标题:r - How to render text in Pashto in a Quarto pdf? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744698283a2620412.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论