Reputation: 953
I usually reference equations in rmd
using \label{}
and \eqref{}
combination. (I know \@ref
, but this seems only works in bookdown::pdf_document
or bookdown::html_document
) For example,
---
title: "Untitled"
author: "Blended"
date: '2019 3 14 '
output:
html_document: default
pdf_document: default
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(comment = "#>")
```
\begin{equation} \label{eq:test}
Y_i = \beta_0 + \beta_1 x_i + \epsilon_i
\end{equation}
Equation $\eqref{eq:test}$ works in PDF, but does not works in HTML.
This works well in pdf
document.
However, when rendering html
, it gives (???)
, not (1)
:
I think this is related to this issue: Support LaTeX environments in Markdown -> HTML conversion, i.e. MathJax occurs the error.
But I cannot see any solution of this.
Is it possible to use \eqref{eq:}
normally in html document?
Upvotes: 1
Views: 2003
Reputation: 23919
Add the following script at the beginning of your document body:
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
TeX: { equationNumbers: { autoNumber: "AMS" } }
});
</script>
It configures MathJax to automatically number equations. More details here.
Upvotes: 5