tests/testit/test-latex.R

library(testit)

assert("insert TeX syntax for bib in toc correctly", {
  (add_toc_bib("\\anything else unchanged") %==% "\\anything else unchanged")
  (add_toc_bib(c("dummyline", "\\bibliography{bib1.bib}")) %==%
    c("dummyline", "\\bibliography{bib1.bib}\n\\addcontentsline{toc}{section}{\\bibname}"))
  (add_toc_bib("\\bibliography{bib1.bib}") %==%
    "\\bibliography{bib1.bib}\n\\addcontentsline{toc}{section}{\\bibname}")
  (add_toc_bib("\\bibliography{bib1.bib,bib2.bib}") %==%
    "\\bibliography{bib1.bib,bib2.bib}\n\\addcontentsline{toc}{section}{\\bibname}")
  (add_toc_bib("\\printbibliography") %==%
    "\\printbibliography[heading=bibintoc]")
  (add_toc_bib("\\printbibliography[title=References]") %==%
    "\\printbibliography[title=References,heading=bibintoc]")
  (add_toc_bib(c("dummyline", "\\printbibliography[title=References]")) %==%
    c("dummyline", "\\printbibliography[title=References,heading=bibintoc]"))
})

Try the bookdown package in your browser

Any scripts or data that you put into this service are public.

bookdown documentation built on Sept. 5, 2021, 5:19 p.m.