# Jekyll Liquid Problem with a Mathjax Expression

**URL:** <https://talk.jekyllrb.com/t/jekyll-liquid-problem-with-a-mathjax-expression/7847>\
**Category:** Help\
**Created:** [December 1, 2022, 3:46am UTC](https://talk.jekyllrb.com/t/jekyll-liquid-problem-with-a-mathjax-expression/7847 "2022-12-01T03:46:08Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![BillRaymond](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/billraymond/32/5963_2.png) [@BillRaymond](https://talk.jekyllrb.com/u/BillRaymond)\
**Post date:** [December 1, 2022, 5:06pm UTC](https://talk.jekyllrb.com/t/jekyll-liquid-problem-with-a-mathjax-expression/7847/2 "2022-12-01T17:06:00Z")

</div>

There are probably quite a few ways to accomplish this, but here are two that came to mind, which I tested and they work:

- Assigning and then displaying a variable
- Raw template tag

However, I will point out, I do not know MathJax and have not tested that element for the code I am sharing. Hopefully, this provides your solution or at least some inspiration 🙂

## ⤵ Assigning and then displaying a variable

In this example, you will assign a variable with the formula you want to display on the page:

```auto
{% assign mj = '$g^{\frac {p-1} {{p_i}^{n_i}}\$' %}
{{mj}}

```

**Output**

```auto
$g^{\frac {p-1} {{p_i}^{n_i}}\$

```

I used the variable `mj`, but you can call it whatever you want. Also, if you have multiple formulas to display on a page, you can reuse the variable name like this:

```auto
Here is a formula that you should be aware of:
{% assign mj = '$g^{\frac {p-1} {{p_i}^{n_i}}\$' %}
{{mj}}

And here is another formula you should be aware of:
{% assign mj = '$g^{\div {p-1} {{p_i}^{n_i}}\$' %}
{{mj}}

```

**Output**

```auto
Here is a formula that you should be aware of:
$g^{\frac {p-1} {{p_i}^{n_i}}\$

And here is another formula you should be aware of:
$g^{\div {p-1} {{p_i}^{n_i}}\$

```

## 🦁 Raw template tag

In this example, you will use the Liquid `raw` tag to display your function. The nice thing about this option is you do not have to do as much coding to assign variables. I do not use this tag on my sites, so my suggestion is to make sure it displays properly within your theme. If it does display properly, this is probably what I would use over assigning a variable.

```auto
Here is a formula:

{% raw %}
$g^{\frac {p-1} {{p_i}^{n_i}}\$
{% endraw %}

```

**Output**

```auto
Here is a formula:
$g^{\frac {p-1} {{p_i}^{n_i}}\$

```

## 🔖 Reference

The `raw` tag is a Liquid `template tag`. If my examples are not exactly what you want, check out the documentation to see if there are other options that might be suitable for your situation:

> **[Template](https://shopify.github.io/liquid/tags/template/)**
>
> An overview of template tags in the Liquid template language.

---

_[View the full topic](https://talk.jekyllrb.com/t/jekyll-liquid-problem-with-a-mathjax-expression/7847)._
