# Switching back and forth from visual and editor mode makes number and reference equation broke.

> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
RStudio Version 1.4.869


Works on source editor mode:

---
title: "Generate number and reference equation"
output:
bookdown::html_document2
---

Sample equation from [Here](https://bookdown.org/yihui/bookdown/markdown-extensions-by-bookdown.html#equations)

$$f\left(k\right) = \binom{n}{k} p^k\left(1-p\right)^{n-k} (\#eq:binom)$$

As, we can see on equation \@ref(eq:binom) above..



It generates like this:

Now, when I firstly switch to visual rmarkdown editor, everything is fine. The code is as it is. Generate the same thing too.
Problem occured when I switch back to source editor mode and switch again to visual mode.
Even when the code still the same, the output become error in label and reference.

Notice the label number is disapear become label text, so the reference is in ??.

Then when I switch back to editor mode, the code is changing (adding more backlash)

---
title: "Generate number and reference equation"
output:
bookdown::html_document2
---

Sample equation from [Here](https://bookdown.org/yihui/bookdown/markdown-extensions-by-bookdown.html#equations)

$$f\\left(k\\right) = \\binom{n}{k} p\^k\\left(1-p\\right)\^{n-k} (\\\#eq:binom) \$$

As, we can see on equation \@ref(eq:binom) above..


And it's seems broke after that. I can't generate an equation with number and reference anymore in visual mode.
I try to switch back again to editor mode, fixing the equation, and generate it. It works. But when I switched again in visual mode, generate it. It won't work.
Any solution for this? Thanks in advance.

That seems like a bug I can reproduce
Would you like to report it on the rstudio github repo ?

Thank you.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.