| Title: | R Markdown to PDF in Thai Language | 
| Version: | 0.1.2 | 
| Description: | Provide R Markdown templates and LaTeX preamble which are necessary for creating PDF from R Markdown documents in Thai language. | 
| License: | MIT + file LICENSE | 
| Depends: | R (≥ 3.4) | 
| Encoding: | UTF-8 | 
| RoxygenNote: | 7.1.2 | 
| Imports: | fs, cli, rmarkdown | 
| Suggests: | testthat (≥ 3.0.0), bookdown, covr, knitr | 
| URL: | https://lightbridge-ks.github.io/thaipdf/ | 
| BugReports: | https://github.com/Lightbridge-KS/thaipdf/issues | 
| Config/testthat/edition: | 3 | 
| VignetteBuilder: | knitr | 
| Language: | th, en-US | 
| NeedsCompilation: | no | 
| Packaged: | 2022-04-20 08:18:28 UTC; kittipos | 
| Author: | Kittipos Sirivongrungson [aut, cre], Dittaya Wanvarie [cph] (Author of an article on Thai language typesetting in LaTeX) | 
| Maintainer: | Kittipos Sirivongrungson <ki11ip0.s.a.s@gmail.com> | 
| Repository: | CRAN | 
| Date/Publication: | 2022-04-22 09:00:02 UTC | 
Convert R Markdown to a PDF book with Thai Language Compatibility
Description
Thai language supported conversion of R Markdown to a PDF after resolving the special tokens of bookdown (e.g., the tokens for references and labels) to native LaTeX commands.
It is a wrapper around bookdown::pdf_book() with argument base_format set to thaipdf_document().
Usage
thaipdf_book(...)
Arguments
... | 
 Arguments to pass to   | 
Value
An S3 object of class "rmarkdown_output_format" to pass to rmarkdown::render()
See Also
How to use
bookdown::pdf_book(), please see official documentationHow to use
thaipdf_document().
Examples
## Not run: 
 library(rmarkdown)
 # Simple Conversion
 render("input.Rmd", output_format = thaipdf::thaipdf_book())
 # Render with Thai font "Laksaman" and font size 10pt
 render("input.Rmd",
        output_format = thaipdf::thaipdf_book(
          thai_font = "Laksaman", # you must have this font in your system
          pandoc_args = pandoc_metadata_arg("fontsize", "10pt")
        ))
## End(Not run)
Convert to a PDF/LaTeX document with Thai Language Compatibility
Description
Thai language supported conversion of R Markdown to a PDF or LaTeX document.
It is a wrapper around rmarkdown::pdf_document().
Usage
thaipdf_document(thai_font = "TH Sarabun New", line_spacing = 1.5, ...)
Arguments
thai_font | 
 (Character) Name of the Thai font to use. Default font is "TH Sarabun New". It can be any Thai font that installed in your system.  | 
line_spacing | 
 (Numeric) Spacing between each line. Line spacing 1.5 is recommended for Thai language (default).  | 
... | 
 Arguments to pass to   | 
Details
To achieve Thai language compatibility for LaTeX,
This function injects preamble fragment of Thai LaTeX typesetting into the preamble of output LaTeX via includes argument,
and set latex_engine to "xelatex".
Value
An S3 object of class "rmarkdown_output_format" to pass to rmarkdown::render()
See Also
How to use
rmarkdown::pdf_document, please see official documentation.How to use
thaipdf_book().
Examples
## Not run: 
library(rmarkdown)
 # Simple Conversion
 render("input.Rmd", output_format = thaipdf::thaipdf_document())
 # Render with Thai font "Laksaman", font size 10pt, enable table of contents
 render("input.Rmd",
        output_format = thaipdf::thaipdf_document(
          thai_font = "Laksaman", # you must have this font in your system
          toc = TRUE,
          pandoc_args = pandoc_metadata_arg("fontsize", "10pt")
        ))
## End(Not run)
Create a LaTeX Preamble for Thai Language in R Markdown
Description
This function creates LaTeX preamble file needed to render Thai language in R Markdown to a PDF document.
Usage
use_thai_preamble(
  name = "thai-preamble.tex",
  thai_font = "TH Sarabun New",
  line_spacing = 1.5,
  open = FALSE,
  overwrite = FALSE
)
Arguments
name | 
 (Character) Thai LaTeX preamble file name or path of file to create, which can be relative path or absolute path. Default value is   | 
thai_font | 
 (Character) Name of the Thai font to use. Default font is "TH Sarabun New". It can be any Thai font that installed in your system.  | 
line_spacing | 
 (Numeric) Spacing between each line. Line spacing 1.5 is recommended for Thai language (default).  | 
open | 
 (Logical) Open the newly created file for editing? Using default editor of   | 
overwrite | 
 (Logical) If file already exist, do you want to overwrite?  | 
Details
Here is the steps:
Call
use_thai_preamble(). You can set other file name bynameargument and Thai font to use bythai_fontargument.Follow the instructions printed to R console.
File
thai-preamble.texshould be created in the current working directory (by default).(If not already) Create R Markdown file with
pdf_document:orbookdown::pdf_document2format.Modify YAML header in
pdf_document:orbookdown::pdf_document2option. Setlatex_enginetoxelatexand set to include path to the LaTeX preamble file.Add LaTeX macro
\sloppyto the beginning of the body of R Markdown (just after YAML header).
Write some Thai language in R Markdown then knit to PDF. It's DONE!
Value
(Invisible) A path to LaTeX preamble being created.
Examples
## Not run: 
 # Running this will write `thai-preamble.tex` to your working directory
 use_thai_preamble()
 # Write `thai-preamble.tex` under pre-tex/ directory (a directory must exist)
 use_thai_preamble(name = "pre-tex/thai-preamble.tex")
 # Specify Thai font to use
 use_thai_preamble(thai_font = "Laksaman")
## End(Not run)
 # Example
 .old_wd <- setwd(tempdir())
 use_thai_preamble()
 setwd(.old_wd)