https://github.com/lightbridge-ks/thaipdf
R Markdown to PDF in Thai language 🇹🇭
https://github.com/lightbridge-ks/thaipdf
latex-template pdf-document r-package rmarkdown thai thai-language
Last synced: 8 months ago
JSON representation
R Markdown to PDF in Thai language 🇹🇭
- Host: GitHub
- URL: https://github.com/lightbridge-ks/thaipdf
- Owner: Lightbridge-KS
- License: other
- Created: 2022-02-12T07:52:47.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-06-13T15:05:47.000Z (over 3 years ago)
- Last Synced: 2025-02-01T22:01:39.030Z (9 months ago)
- Topics: latex-template, pdf-document, r-package, rmarkdown, thai, thai-language
- Language: TeX
- Homepage: https://lightbridge-ks.github.io/thaipdf
- Size: 3.76 MB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---```{r, include = FALSE}
# from: https://github.com/mitchelloharawild/vitae/blob/master/README.Rmd
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```[](https://lifecycle.r-lib.org/articles/stages.html#experimental) [](https://CRAN.R-project.org/package=thaipdf) [](https://github.com/Lightbridge-KS/thaipdf/actions) [](https://app.codecov.io/gh/Lightbridge-KS/thaipdf) [](https://github.com/Lightbridge-KS/thaipdf/actions/workflows/pkgdown.yaml)
> R package :package: ช่วยสร้าง PDF document จาก R Markdown ที่ใช้ **ภาษาไทย :thailand:**
```{r show-previews, echo=FALSE, results='asis'}
knitr::kable(
tibble::tibble(
`1` = "",
`2` = ""
),
escape = FALSE
)
```# Goal
R package นี้ช่วย**สร้าง PDF เป็นภาษาไทย :thailand: จาก [R Markdown](https://rmarkdown.rstudio.com) ได้โดยง่าย**
- **ผู้เริ่มต้น** สามารถ **knit** เอกสาร R Markdown เป็น PDF ได้ทันทีโดยใช้ template ที่มีให้ และ
- **ผู้ที่ใช้งาน [LaTeX](https://www.latex-project.org) เป็น** สามารถเรียกใช้ LaTeX preamble ที่มีการตั้งค่าภาษาไทยมาให้แล้ว มา customize เพิ่มเติมอย่างที่ต้องการได้
โดยจะพยามคง option ต่างๆ ของ R Markdown ไว้ให้ได้มากที่สุด ซึ่งสามารถส่งต่อ YAML parameter ไปยัง R Markdown หรือ bookdown ได้ด้วย
# Install
**Install thaipdf:**
- ติดตั้งจาก CRAN ด้วย:
``` r
install.packages("thaipdf")
```- หรือติดตั้ง development version จาก [GitHub](https://github.com/Lightbridge-KS/thaipdf) ด้วย:
``` r
# install.packages("remotes")
remotes::install_github("Lightbridge-KS/thaipdf")
```**Install XeLaTeX และ LaTeX package** ที่จำเป็นสำหรับการใช้ภาษาไทย อาจทำได้อย่างง่ายโดยใช้ [{tinytex}](https://yihui.org/tinytex/) R package:
``` r
install.packages("tinytex")# For using R Markdown
tinytex::install_tinytex()# Install LaTeX PKG required by `thaipdf`
tinytex::tlmgr_install(c(
"fontspec", "ucharclasses", "polyglossia"
))
```**Check font:** ตรวจสอบว่าในเครื่องมีฟอนท์ [TH Sarabun New](https://www.f0nt.com/release/th-sarabun-new/) ถ้าไม่มีให้ติดตั้งด้วย (เนื่องจาก thaipdf ใช้ font นี้เป็นตัวหลัก)
# Usage
วิธีใช้ที่ง่ายที่สุด คือสร้าง R Markdown ที่รองรับภาษาไทยจาก template ที่ package นี้มีให้
ถ้าท่านใช้ RStudio ให้ไปที่ `File -> New File -> R Markdown... -> From Template`
เลือก template **Thai PDF R Markdown** หรือ **Thai PDF Bookdown** จากเมนู
กดปุ่ม **`OK`** จะเปิดไฟล์ R Markdown template ที่รองรับกับภาษาไทย
จากนั้นกดปุ่ม **`Knit`** (cmd/ctr + shift + K) ได้เลย จะได้เอกสารเป็น PDF ภาษาไทยที่มี เนื้อหา โค้ด และ กราฟ อยู่รวมกัน

# Learn more
- [**Get Started with thaipdf**](https://lightbridge-ks.github.io/thaipdf/articles/thaipdf.html)
------------------------------------------------------------------------
Last Updated: `r Sys.Date()`