18
0

fix color hook for newer knitr versions

Newer knitr injects \usepackage[]{xcolor} instead of \usepackage[]{color},
so the old hook never matched and dvipsnames colors (e.g. Blue) were undefined.
This commit is contained in:
2026-03-21 15:53:47 +09:00
parent 54c07cb9f5
commit ec596703e2

View File

@@ -12,8 +12,11 @@
<<init, echo=FALSE>>=
knit_hooks$set(document = function(x) {
sub('\\usepackage[]{color}',
x <- sub('\\usepackage[]{color}',
'\\usepackage[usenames,dvipsnames]{color}', x, fixed = TRUE)
x <- sub('\\usepackage[]{xcolor}',
'\\usepackage[usenames,dvipsnames]{xcolor}', x, fixed = TRUE)
x
})
opts_chunk$set(fig.path="figures/knitr-")