[Rd] Rd macros are not expanded inside of \eqn{} or \deqn{}
Mikael Jagan
j@g@nmn2 @end|ng |rom gm@||@com
Mon Jun 12 19:55:16 CEST 2023
I was a bit surprised to learn that, if one has an Rd file as below:
%% zzz.Rd
\newcommand{\zzz}{whatever}
\name{zzz}
\title{zzz}
\description{ \zzz{} \eqn{\zzz{}} \deqn{\zzz{}} }
then the macro is _not_ expanded inside of \eqn{} or \deqn{} when parsed to text
or HTML. Is this behaviour intentional? Could it be changed? Inside of \eqn{}
and \deqn{} is where I am _most_ likely to want to use macros, at least since
R 4.2.0, which added KaTeX support ...
See output pasted below.
Mikael
> tools::Rd2txt(tools::parse_Rd("zzz.Rd"))
zzz
Description:
whatever \zzz{}
\zzz{}
> tools::Rd2HTML(tools::parse_Rd("zzz.Rd"))
<!DOCTYPE html><html><head><title>R: zzz</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0,
user-scalable=yes" />
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/katex@0.15.3/dist/katex.min.css">
<script type="text/javascript">
const macros = { "\\R": "\\textsf{R}", "\\code": "\\texttt"};
function processMathHTML() {
var l = document.getElementsByClassName('reqn');
for (let e of l) { katex.render(e.textContent, e, { throwOnError: false,
macros }); }
return;
}</script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.15.3/dist/katex.min.js"
onload="processMathHTML();"></script>
<link rel="stylesheet" type="text/css" href="R.css" />
</head><body><div class="container">
<table style="width: 100%;"><tr><td>zzz</td><td style="text-align: right;">R
Documentation</td></tr></table>
<h2 id='zzz'>zzz</h2>
<h3>Description</h3>
<p>whatever <code class="reqn">\zzz{}</code> </p>
<p style="text-align: center;"><code class="reqn">\zzz{}</code>
</p>
</div>
</body></html>
More information about the R-devel
mailing list