# 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")
2条答案
按热度按时间slhcrj9b1#
我可以提出这个基于pandoc lua filter的解决方案,它不仅适用于pdf,也适用于html输出,而且不需要手动编辑latex或html文件。
We used
R
[@R-base] andTidyverse
[@R-tidyverse] for all our analyses. Especially [@R-tidyverse] made things easy.\vspace{10mm}
References
function Cite(el)
if pandoc.utils.stringify(el.content) == "[@R-tidyverse]" then
return (pandoc.Strong(el))
end
end
efzxgjgh2#
发布一个解决方案,以防它对其他人也有用。我们可以首先从RMarkdown文档渲染LaTeX文件,然后找到并替换所有需要强调的名称,最后从修改后的LaTeX文件生成pdf。