The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

thaipdf

Lifecycle: experimental R-CMD-check codecov pkgdown

R package :package: ช่วยสร้าง PDF document จาก R Markdown ที่ใช้ ภาษาไทย :thailand:

1 2
Thai book example 1 Thai book example 2

Goal

R package นี้ช่วยสร้าง PDF เป็นภาษาไทย :thailand: จาก R Markdown ได้โดยง่าย

โดยจะพยามคง option ต่างๆ ของ R Markdown ไว้ให้ได้มากที่สุด ซึ่งสามารถส่งต่อ YAML parameter ไปยัง R Markdown หรือ bookdown ได้ด้วย

Install

Install thaipdf: ติดตั้ง development version ของ thaipdf จาก GitHub ด้วย:

# install.packages("remotes")
remotes::install_github("Lightbridge-KS/thaipdf")

Install XeLaTeX และ LaTeX package ที่จำเป็นสำหรับการใช้ภาษาไทย อาจทำได้อย่างง่ายโดยใช้ {tinytex} R package:

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 ถ้าไม่มีให้ติดตั้งด้วย (เนื่องจาก thaipdf ใช้ font นี้เป็นตัวหลัก)

Usage

วิธีใช้ที่ง่ายที่สุด คือสร้าง R Markdown ที่รองรับภาษาไทยจาก template ที่ package นี้มีให้

ถ้าท่านใช้ RStudio ให้ไปที่ File -> New File -> R Markdown... -> From Template

New R Markdown Template

เลือก template Thai PDF R Markdown หรือ Thai PDF Bookdown จากเมนู

กดปุ่ม OK จะเปิดไฟล์ R Markdown template ที่รองรับกับภาษาไทย

thaipdf R Markdown in RStudio

จากนั้นกดปุ่ม Knit (cmd/ctr + shift + K) ได้เลย จะได้เอกสารเป็น PDF ภาษาไทยที่มี เนื้อหา โค้ด และ กราฟ อยู่รวมกัน

ตัวอย่าง R Markdown PDF ภาษาไทย

Learn more


Last Updated: 2022-04-12

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.