# Colorised LaTEX formula

I tried to use https://www.codecogs.com/latex/eqneditor.php to make a font effect on LaTEX formula, however :

Basic LaTEX formula :

\begin{align*} Y& = \beta_{0} + \beta_{1}X_{1} + \beta_{2}X_{2} + \beta_{3}X_{1}X_{2}\\ &= \beta_{0} + \widetilde{\beta_{1}}X_{1} + \beta_{2}X_{2}; \widetilde{\beta_{1}} = \beta_{1} + \beta_{2}X_{2}\\ \end{align*}

\begin{align*} Y& = \beta_{0} + \beta_{1}X_{1} + \beta_{2}X_{2} + \beta_{3}X_{1}X_{2}\\ &= \beta_{0} + \widetilde{\beta_{1}}X_{1} + \beta_{2}X_{2}; \widetilde{\beta_{1}} = \beta_{1} + \beta_{2}X_{2}\\ \end{align*}

Highlighed LaTEX formula :

\begin{align*} Y& = \beta_{0} + \beta_{1}X_{1} + \beta_{2}X_{2} + \beta_{3}X_{1}X_{2}\\ &= \beta_{0} + {\color{Red} \widetilde{\beta_{1}}}X_{1} + \beta_{2}X_{2}; {\color{Red} \widetilde{\beta_{1}}} = \beta_{1} + \beta_{2}X_{2}\\ \end{align*}

\begin{align*} Y& = \beta_{0} + \beta_{1}X_{1} + \beta_{2}X_{2} + \beta_{3}X_{1}X_{2}\\ &= \beta_{0} + {\color{Red} \widetilde{\beta_{1}}}X_{1} + \beta_{2}X_{2}; {\color{Red} \widetilde{\beta_{1}}} = \beta_{1} + \beta_{2}X_{2}\\ \end{align*}

I noticed it doesn't work...

source image : https://www.awesomescreenshot.com/showImage?img_id=5503293

Refrence

From your sreenshot, I suppose you aim at a HTML output ?

The behavior you encounter is because of the MathJax version used. By default, Rmarkdown is using version 2.7 and the syntax is not what you wrote.

in version 2, you would do
\color{red}{x} + \color{blue}{y}
to get a red x added to a blue y . But in version 3 (and in LaTeX itself), you would do
{\color{red} x} + {\color{blue} y}

You used the second.

This works:

---
title: "test"
output:
html_document:
mathjax: default
---

$$\color{Red}{\widetilde{\beta_{1}}}X_{1}$$


You can also change the mathjax version I believe (but I don't know if there could be some unwanted behavior with some of the rmarkdown features.

This works

---
title: "test"
output:
html_document:
mathjax: https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
---

$${\color{Red} \widetilde{\beta_{1}}}X_{1}$$


This does not

---
title: "test"
output:
html_document:
mathjax: default
---

$${\color{Red} \widetilde{\beta_{1}}}X_{1}$$


Hope it helps.

\begin{align*}
\color{Red} \widetilde{\beta_{1}}X_{1}\\

{\color{Red} \widetilde{\beta_{1}}}X_{1}\\
\end{align*}


I noticed only support basic LaTEX formula, advanced formula required to solve it... looking for assist

What are you asking exactly ? support for the \widetilde command ?
It is supported in Mathjax
http://docs.mathjax.org/en/latest/input/tex/macros/index.html?highlight=widetilde

and the example above are working when you knit the document to html. Is it not working for you ?

title: "test"
output:
html_document:
mathjax: https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js


this mathjax: http://docs.mathjax.org/en/latest/input/tex/macros/index.html?highlight=widetilde doesn't work as well, error as shown in picture...

Can you try by going to line and indenting correctly the yaml as in my example? Indentation is important in yaml.

Also please shared code and not capture of code. I can't see the part of the code that does not work in your screenshot

or here is the screenshot video : https://www.youtube.com/watch?v=DOEK8VqWcP0

Unfortunately video on mobile phone does not help, it is too small to see the detail. Please share a reproducible example (FAQ: What's a reproducible example (reprex) and how do I do one?) as I did here above: Colorised LaTEX formula

Did you run the snippet of code I published above ? What is not working for you in those example ?

Your example in first post with \wildetilde works if you use a newer version of Mathjax as explained

---
title: "test"
output:
html_document:
mathjax: https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
---

\begin{align*} Y& = \beta_{0} + \beta_{1}X_{1} + \beta_{2}X_{2} + \beta_{3}X_{1}X_{2}\\ &= \beta_{0} + {\color{Red} \widetilde{\beta_{1}}}X_{1} + \beta_{2}X_{2}; {\color{Red} \widetilde{\beta_{1}}} = \beta_{1} + \beta_{2}X_{2}\\ \end{align*}


It will work with default mathjax, if you change the syntax for color as explained above.

What do you expect differently ?