Reputation: 85
It seems i can't reference equations, lemas, etc when inside math.
In the following example the tag eq:test
cant be referenced inside the align
, but it works fine outside.
---
title: "Test"
site: bookdown::bookdown_site
documentclass: article
---
If
\begin{equation}
A = B
(\#eq:test)
\end{equation}
then
\begin{align*}
A \ &= B &&, \text{ by } \@ref(eq:test) \\ % this will not work
&= C
\end{align*}
But here \@ref(eq:test) it works.
I want to know if this is currently not possible or i'm missing some special notation to make it work.
Upvotes: 1
Views: 183
Reputation: 20087
Try with latex command \label{}
and \eqref{}
.
\label
, \eqref
works smoothly for pdf output as expected. For html output, we need to configure the Tex component of mathjax through the tex block as instructed here.
---
title: "Test"
output:
bookdown::pdf_document2:
documentclass: article
bookdown::html_document2: default
---
```{=html}
<script>
MathJax = {
tex: {
tags: 'all'
}
};
</script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
```
If
\begin{equation}
A = B \label{test-eq1}
\end{equation}
then
\begin{align*}
A \ &= B &&, \text{ by } \eqref{test-eq1} \\
&= C
\end{align*}
But here \eqref{test-eq1} it works.
pdf output
html output
Upvotes: 1