knitr::opts_knit$set(root.dir = rprojroot::find_rstudio_root_file()) # Set WD to Root here::i_am("my_dev/plan.Rmd") library(here)
Nomenclatures: DEV (for developer), USER (for user)
inst/
rmarkdown/
Thai PDF R Markdown
Thai PDF R Markdown (with preamble)
templates/
pre-tex/
When update config param, I must Update
config.yml
, template-thai-preamble.tex
thaipdf_config_set()
, thaipdf_config_validate()
, print.thaipdf_config()
templates/
fs::file_create(here("inst/templates/config.yml")) fs::file_create(here("inst/templates/template-thai-preamble.tex"))
pre-tex/
fs::dir_create(here("inst/pre-tex"))
rmarkdown/
thai-pdf-rmd-w-pre/
# usethis::use_rmarkdown_template( # template_name = "Thai PDF R Markdown (with preamble)", # template_description = "R Markdown PDF template with LaTeX preamble file that supports Thai language.", # template_create_dir = TRUE # )
thai-pdf-rmd/
usethis::use_rmarkdown_template( template_name = "Thai PDF R Markdown", template_dir = "thai-pdf-rmd", template_description = "R Markdown PDF stand-alone template that supports Thai language.", template_create_dir = FALSE )
thai-pdf-book/
usethis::use_rmarkdown_template( template_name = "Thai PDF Bookdown", template_dir = "thai-pdf-book", template_description = "R Markdown PDF stand-alone template using Bookdown that supports Thai language.", template_create_dir = FALSE )
usethis::use_r("path") usethis::use_test("path")
th_pre
= Thai preamble file name
thaipdf_paths <- function(th_pre = "thai-preamble.tex") { ## Template file name temp_filename <- paste0("template-", th_pre) # Input Path ## Template path path_temp <- fs::path_package("thaipdf", "templates", temp_filename) ## config.yml path path_config <- fs::path_package("thaipdf", "templates", "config.yml") # Output Path ## Global Preamble at pre-tex/ path_pre_global <- fs::path_package("thaipdf", "pre-tex", th_pre) ## Global pre-tex/before_body.tex for \sloppy macro path_before_body <- fs::path_package("thaipdf", "pre-tex", "before_body.tex") ## At rmarkdown/ ### Thai PDF with Preamble (for Project) path_pre_proj <- fs::path_package("thaipdf", "rmarkdown", "templates", "thai-pdf-rmd-w-pre", "skeleton", "pre-tex", th_pre) list( path_temp = path_temp, path_config = path_config, path_pre_global = path_pre_global, path_before_body = path_before_body, path_pre_proj = path_pre_proj ) } thaipdf_paths()
fs::path_package("thaipdf") # File ## Input Template File Name paste0("template-",file_names$th_pre) ## Output TeX Preamble File Name file_names$th_pre # Path ## Input Location path fs::path_package("thaipdf", "templates", paste0("template-", file_names$th_pre)) ## Input Metadata path fs::path_package("thaipdf", "templates", "config.yml") # Output Location ## pre-tex/ fs::path_package("thaipdf", "pre-tex") ## rmarkdown/ ### Thai PDF with Preamble fs::path_package("thaipdf", "rmarkdown", "templates", "thai-pdf-rmd-w-pre", "skeleton", "pre-tex", "thai-preamble.tex")
thaipdf_config
thaipdf_config
create_*
: create "class_name" & set ... attributenew_thaipdf_config
: add "thaipdf_config" class to existing list is_thaipdf_config
: check classthaipdf_config
print.thaipdf_config()
: print thaipdf_config
object nicely to consoleuse_thai_preamble()
: create PROJECT-based thai-preamble.tex
from template template-thai-preamble.tex
thaipdf_config_set()
: render USER-based thai-preamble
in rmarkdown/
and pre-tex/
folder from template template-thai-preamble.tex
with metadata from config.yml
thaipdf_config_get()
: read config.yml
and print to console nicely
fun1
:
fun2
:
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.