Last active
January 2, 2023 13:04
-
-
Save lnalborczyk/548cf62fe5b9e4588c711205c0342fdb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ########################################################### | |
| # Emphasising some references in a RMarkdown document # | |
| # ------------------------------------------------------- # | |
| # Written by Ladislas Nalborczyk # | |
| # Contact: ladislas.nalborczyk@gmail.com # | |
| # Last updated on January 2, 2023 # | |
| ########################################################### | |
| # knitting the original Rmd file (with "keep_tex: true" in YAML) | |
| rmarkdown::render(input = "some_file.Rmd") | |
| # reading the generated LaTeX file | |
| tex_file <- readLines(con = "some_file.tex") | |
| # putting a particular author in bold in the references list | |
| new_tex_file <- gsub(pattern = "James, W.", replace = "\\textbf{James, W.}", x = tex_file, fixed = TRUE) | |
| # writing the (updated) LaTeX file | |
| writeLines(text = new_tex_file, con = "some_file.tex") | |
| # generating the pdf file (may need to be ran twice) | |
| system(command = "xelatex some_file.tex") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment