-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
104 lines (67 loc) · 4.98 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{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%"
)
```
# thaipdf <a href="https://lightbridge-ks.github.io/thaipdf/"><img src="man/figures/logo.png" align="right" height="138"/></a>
<!-- badges: start -->
[](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)
<!-- badges: end -->
> 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`
<img src="man/figures/rmd-from-temp.png" alt="New R Markdown Template" width="500"/>
เลือก template **Thai PDF R Markdown** หรือ **Thai PDF Bookdown** จากเมนู
กดปุ่ม **`OK`** จะเปิดไฟล์ R Markdown template ที่รองรับกับภาษาไทย
<img src="man/figures/rstudio-rmd.png" alt="thaipdf R Markdown in RStudio" width="600"/>
จากนั้นกดปุ่ม **`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()`