在带有 pdf 输出的 Rmarkdown 中使用英语和希腊语会产生冲突

问题描述

您好,我正在尝试使用希腊语和英语以 pdf 格式从 Rmarkdown 打印报告,我尝试了此代码

---
output: 
bookdown::pdf_document2:
toc: true
number_sections: true
header-includes:
- \usepackage{amsmath}
- \usepackage{graphicx}
- \usepackage{hyperref}
- \usepackage[utf8]{inputenc}
- \usepackage[english,greek]{babel}
- \newcommand{\en}[1]{{\selectlanguage{english}#1}}
- \newcommand{\gr}[1]{{\selectlanguage{greek}#1}}
---
---
title: \gr{Δοκιμαστικό}
subtitle: \en{Company  S.A.}
---
```{r warning=FALSE,include=FALSE}
Sys.setlocale("LC_TIME","English")
```
---
date: "_`r format(Sys.time(),'%d %B,%Y')`_"
---
---
abstract: 
---
\listoffigures
\listoftables

\section{section}
\subsection{subsection}
\subsection{subsection}

它给了我这个错误

Try other LaTeX engines instead (e.g.,xelatex) if you are using pdflatex. See https://bookdown.org/yihui/rmarkdown-cookbook/latex-unicode.html
Error: LaTeX Failed to compile file.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See file.log for more info.
In addition: Warning message:
In has_crop_tools() : 
Tool(s) not installed or not in PATH: ghostcript
-> As a result,figure cropping will be disabled.
Execution halted

但是当我用 Dokimastiko 替换 Δοκιμαστικό 时,它会打印出我

enter image description here

当我使用此代码

---
output:
   pdf_document:
     latex_engine: xelatex
toc: true
number_sections: true
header-includes:
- \usepackage{amsmath}
- \usepackage{graphicx}
- \usepackage{hyperref}
- \usepackage[utf8]{inputenc}
- \usepackage[english,%Y')`_"
---

它给了我这个

enter image description here

嗯,这不是我的情况的解决方案,而且自动日期打印不正确,有没有其他方法可以同时使用希腊语和英语而不发生冲突?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)