pandocquartoarabic-supportxelatex

How to render non-latin scripts like Arabic into pdf format with Quarto?


When I write YAML code in the Quarto config file to include latex commands that render Arabic nicely into pdf it works fine. The same YAML code does not work in Quarto.

This is the code that works in plain markdown, but not in the Quarto config file (_quarto.yml):

header-includes:
  - |
    ```{=latex}
    \usepackage{babel}
    \babelfont[arabic]{rm}[Scale=1.2]{Amiri}

I use Quarto with VSCodium, and as far as I know, it uses the same pdf engine (xelatex) as when I render plain .md files. I get the following error message in the terminal when I try to render:

In file _quarto.yml
(line 34, column 7) Array entry 1 is empty but it must instead be a string.
33:     header-includes:
34:     - |
         ~
35:       ```{=latex}

If I delete the header-includes lines my .qmd documents render nicely into pdf, except that there are just blanks where the Arabic script should have been.


Solution

  • You do not need to use the latex block to include raw contents. Use include-in-header and the text subkey instead. From the documentation,

    To include raw content in the YAML header, use the text subkey. When using text:, add the | character after text: to indicate that the value is a multi-line string.

    So try as the following,

    include-in-header:
       text: |
        \usepackage{babel}
        \babelfont[arabic]{rm}[Scale=1.2]{Amiri}