On Sat, 23 Jan 2021 04:54:51 -0500 Duncan Murdoch <murdoch.dun...@gmail.com> wrote:
> I wonder if there's a way to define stubs for the macros in the > package, and use mathjaxr versions only conditional on having it > available? I had an idea along the lines of \Sexpr[results=rd]{if (...) '\\newcommand{\\mjeqn}{...}'} ...but \Sexpr seems to be expanded too late in the Rd processing pipeline for the \newcommand to have any effect. This also seems to mean that it's impossible to dynamically load macro definitions belonging to a different package from a \Sexpr: % doesn't affect the rest of the document \Sexpr[results=rd]{ if (nzchar(f <- system.file('help/macros/mathjax.Rd', 'mathjaxr'))) readLines(f) } An "optional mathjaxr" implementation will probably end up with its own copy of man/macros/mathjax.Rd (but not the rest of MathJax), with \mjeqn and friends defined to check whether mathjaxr package is available before outputting MathJax markup or \eqn. Loading the rest of the .Rd in the same \Sexpr where \newcommand{} is evaluated (1) doesn't work because only one Rd section per \Sexpr is supported and (2) would be a truly horrible hack if it worked. -- Best regards, Ivan ______________________________________________ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel