Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lightbridge-ks/quarto-book-thai-pdf

Example repo for render Quarto Book to PDF in Thai language ๐Ÿ‡น๐Ÿ‡ญ
https://github.com/lightbridge-ks/quarto-book-thai-pdf

pdf quarto thai-language

Last synced: 8 days ago
JSON representation

Example repo for render Quarto Book to PDF in Thai language ๐Ÿ‡น๐Ÿ‡ญ

Awesome Lists containing this project

README

        

# Quarto Book in Thai Language with PDF

> This repo demonstrate how to use **Thai language ๐Ÿ‡น๐Ÿ‡ญ** in a **[Quarto Book](https://quarto.org/docs/books/)** that renders to **PDF**.

## Introduction

Quarto book in Thai language can be rendered to MS Word or HTML format out of the box, but **PDF requires some setup**. I'll show you how to do that in this tutorial.

The key is to include thai language setting in the LaTeX preamble of the Quarto book.

## Example

These are the output of this repo:

- [**PDF Book in Thai**](./docs/Quarto-Book-เน„เธ—เธข.pdf) (and [LaTeX output](Quarto-Book-เน„เธ—เธข.tex))
- [**HTML Book**](https://lightbridge-ks.github.io/quarto-book-thai-pdf/)

## Step 1: Create Quarto Book

Create Quarto book skeleton as [explained here](https://quarto.org/docs/books/), then enter into your book directory.

## Step 2: Get Thai LaTeX Preamble Setting

If you use `R`, [`{thaipdf}`](https://lightbridge-ks.github.io/thaipdf/) R package can automate this process.

Simply call the following function in your book project.

```r
# install.packages("thaipdf")
thaipdf::use_thai_preamble()
```

It will create [`thai-preamble.tex`](thai-preamble.tex) in your project, which is a LaTeX preamble that enable Thai language type-setting with Thai font default to [TH Sarabun New](https://www.f0nt.com/release/th-sarabun-new/) (please check that this font is installed)

## Step 3: Include Thai Preamble

In the Quarto config (`_quarto.yml` or `_metadata.yml`), add `thai-preamble.tex` to [include in the LaTeX preamble](https://quarto.org/docs/output-formats/pdf-basics.html#latex-includes) to the `pdf` field, like so.

[**`_quarto.yml`**](./_quarto.yml)

```yml
format:
pdf:
include-in-header: "thai-preamble.tex"
```

(You can also keep intermediate LaTeX for debugging with `keep-tex: true`)

This book is now ready to be rendered as PDF with Thai font.

```shell
quarto render
```

It's done!