Skip to content

Instantly share code, notes, and snippets.

@lnalborczyk
Last active January 2, 2023 13:04
Show Gist options
  • Select an option

  • Save lnalborczyk/548cf62fe5b9e4588c711205c0342fdb to your computer and use it in GitHub Desktop.

Select an option

Save lnalborczyk/548cf62fe5b9e4588c711205c0342fdb to your computer and use it in GitHub Desktop.
###########################################################
# 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