knitr::opts_knit$set(root.dir = rprojroot::find_rstudio_root_file()) # Set WD to Root here::i_am("dev/use-th-pre-impr.Rmd") library(here)
use_thai_preamble()
Relative to WD
use_thai_preamble("some_file")
: some_file at current wd -> Worksuse_thai_preamble("../some_file")
: 1 level up -> Worksuse_thai_preamble("out/some_file")
: 1 level down -> WorksCreate at arbitrary location
use_thai_preamble("~/new_file")
or use_thai_preamble("/../../new_file")
We need to test rmarkdown::pandoc_template()
template
and output
args only accept ABSOLUTE pathplan using fs::path_abs()
to wrap output
since, it accept both relative path to WD and absolute path
getwd()
Works
rmarkdown::pandoc_template( metadata = list(thai_font = "Somefonts", line_spacing = 2), template = thaipdf:::thaipdf_paths()[["path_temp"]], # To Relative Location to WD output = fs::path_abs("dev/test_data/test-thai-preamble.tex") )
Works
# rmarkdown::pandoc_template( # metadata = list(thai_font = "Somefonts", line_spacing = 2), # template = thaipdf:::thaipdf_paths()[["path_temp"]], # # To Absolute Location # output = fs::path_abs("/Users/kittipos/my_pkg/test-thai-preamble.tex") # )
tmpdir <- tempdir() file.path(tempdir(), "thai-preamble.tex")
# the same fs::file_show(tmpdir) fs::file_show(tempdir())
rmarkdown::pandoc_template( metadata = list(thai_font = "Somefonts", line_spacing = 2), template = thaipdf:::thaipdf_paths()[["path_temp"]], # To Relative Location to WD output = fs::path_abs(file.path(tempdir(), "thai-preamble.tex")) ) # fs::file_show(tempdir()) fs::file_exists(file.path(tempdir(), "thai-preamble.tex"))
tmp_file <- file.path(tempdir(), "thai-preamble.tex") thaipdf::use_thai_preamble(tmp_file) fs::file_exists(tmp_file) # fs::file_show(tempdir()) #unlink(tmp_file)
.old_wd <- setwd(tempdir()) thaipdf::use_thai_preamble() fs::file_exists("thai-preamble.tex") #fs::file_show("thai-preamble.tex") unlink("thai-preamble.tex") setwd(.old_wd)
.old_wd <- setwd(tempdir()) thaipdf::use_thai_preamble()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.