This repo demonstrate how to use Thai language 🇹🇠in a Quarto Book that renders to PDF.
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.
These are the output of this repo:
Create Quarto book skeleton as explained here, then enter into your book directory.
If you use R
, {thaipdf}
R package can automate this process.
Simply call the following function in your book project.
# install.packages("thaipdf")
thaipdf::use_thai_preamble()
It will create 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 (please check that this font is installed)
In the Quarto config (_quarto.yml
or _metadata.yml
), add thai-preamble.tex
to include in the LaTeX preamble to the pdf
field, like so.
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.
quarto render
It's done!