# How to suppress equation numbers in Franklin?

**URL:** https://discourse.julialang.org/t/how-to-suppress-equation-numbers-in-franklin/73835
**Category:** General Usage
**Tags:** question, web, latex, franklin
**Created:** [December 30, 2021, 8:14pm UTC](https://discourse.julialang.org/t/how-to-suppress-equation-numbers-in-franklin/73835 "2021-12-30T20:14:14Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![mpf01](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mpf01/32/8221_2.png) [@mpf01](https://discourse.julialang.org/u/mpf01)
#### Post date: [December 30, 2021, 8:14pm UTC](https://discourse.julialang.org/t/how-to-suppress-equation-numbers-in-franklin/73835/1 "2021-12-30T20:14:14Z")

</div>

It seems that [Franklin.jl](https://github.com/tlienart/Franklin.jl) doesn’t currently support the “\*” form of math environments, which are used to suppress equation numbers (see this [issue](https://github.com/tlienart/Franklin.jl/issues/629)). For example, the fragment

```julia
\begin{equation*}
  \alpha
\end{equation*}

```

throws an error:

```julia
Franklin.LxObjError("Command or environment 'equation*' was used before it was\ndefined.")

```

Using `\notag` inside the equation doesn’t throw an error:

```julia
\begin{equation}
  \notag
  \alpha
\end{equation}

```

but it renders as

```julia
\[\notag \alpha \]

```

How can equation numbers be suppressed?

---

<div class="post-metadata">

### Author: ![runjaj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/runjaj/32/23628_2.png) [@runjaj](https://discourse.julialang.org/u/runjaj)
#### Post date: [December 30, 2021, 9:57pm UTC](https://discourse.julialang.org/t/how-to-suppress-equation-numbers-in-franklin/73835/2 "2021-12-30T21:57:29Z")

</div>

It’s well explained here:

[https://franklinjl.org/faq/technical/#how\_to\_disable\_numbering\_of\_math\_in\_display\_mode](https://franklinjl.org/faq/technical/#how_to_disable_numbering_of_math_in_display_mode)

(Sorry for the brief answer, I’m replying with my phone.)

---

<div class="post-metadata">

### Author: ![mpf01](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mpf01/32/8221_2.png) [@mpf01](https://discourse.julialang.org/u/mpf01)
#### Post date: [January 1, 2022, 7:02pm UTC](https://discourse.julialang.org/t/how-to-suppress-equation-numbers-in-franklin/73835/3 "2022-01-01T19:02:59Z")

</div>

Thanks for the pointer, @runjaj.

The css modification does indeed suppress the equation number. However, it doesn’t have the corresponding effect on `\eqref`, which references equations as if they had **all** been numbered.

Here’s an [example](http://friedlander.io/FranklinEquations/) (and [repo](https://github.com/mpf/FranklinEquations/blob/master/index.md)) that shows the incorrect reference generated by `\eqref`.

---

<div class="post-metadata">

### Author: ![tlienart](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tlienart/32/7640_2.png) [@tlienart](https://discourse.julialang.org/u/tlienart)
#### Post date: [January 1, 2022, 8:32pm UTC](https://discourse.julialang.org/t/how-to-suppress-equation-numbers-in-franklin/73835/4 "2022-01-01T20:32:07Z")

</div>

That’s correct, it’s actually a bit subtle, thanks for reporting it.

### The solution

In your `utils.jl` copy-paste this:

```julia-auto
function lx_nonumber(com, _)
    Franklin.PAGE_EQREFS[Franklin.PAGE_EQREFS_COUNTER] -= 1
    return "@@nonumber " * Franklin.content(com.braces[1]) * "@@"
end

```

in your `*.css` paste similar to the doc linked in the earlier comment:

```css
.nonumber .katex-display::after {
  counter-increment: nothing;
  content: "";
}

```

Now if you have something like this:

```julia-auto
$$
x = 1 \label{eq1}
$$

\nonumber{
$$
x = 2
$$
}

$$
x = 3 \label{eq2}
$$

\eqref{eq1} and \eqref{eq2}

```

It will show this:

 ![Screenshot 2022-01-01 at 21.27.03](https://global.discourse-cdn.com/julialang/original/3X/2/7/279f824c06fc0adf938fc3662307a8e5c7a6f470.png)

(the vertical alignment is something different that can be adjusted by fiddling with CSS but I’m assuming this is not your most immediate concern; **edit** see note at the bottom though)

### A bit of background

The solution with the CSS is only a trick with the CSS displaying a counter; that CSS counter is not read by Franklin. Franklin instead keeps track of all the equation labels for a page in a dictionary `PAGE_EQREFS` which has a special entry `PAGE_EQREFS_COUNTER` which gets incremented every time a display math block is seen.

This procedure is blind to the fact that you wrapped the block in a div with a class that does some CSS tricks; and so, as you pointed out, the refs are incorrect (in the example above you would have gotten `(2) and (4)` even though the third equation showed with a `(3)`.

The `lx_nonumber` adjusts the counter accordingly.

I hope this makes sense; I might bake this into Franklin since other users might want to use something like this and the solution is not directly obvious. ~~I’ll open an issue with this~~ [Equations without numbers and eqref · Issue #939 · JuliaDocs/Franklin.jl · GitHub](https://github.com/tlienart/Franklin.jl/issues/939).

### css trickery

**edit** if you use

```julia-auto
.nonumber .katex-display::after {
  counter-increment: nothing;
  content: "\00a0\00a0\00a0\00a0";
}

```

the vertical alignment issue in the example above will be fixed if you only have single-digit equations. The `\00a0` is an escaped space (oh the wonderful world of css…)

---

<div class="post-metadata">

### Author: ![mpf01](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mpf01/32/8221_2.png) [@mpf01](https://discourse.julialang.org/u/mpf01)
#### Post date: [January 1, 2022, 8:49pm UTC](https://discourse.julialang.org/t/how-to-suppress-equation-numbers-in-franklin/73835/5 "2022-01-01T20:49:02Z")

</div>

Thanks for the solution, @tlienart! Although I verified that it works on the example site I posted, I left it in its original state, since otherwise it might be confusing to others reading the original post.

---

<div class="post-metadata">

### Author: ![tlienart](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tlienart/32/7640_2.png) [@tlienart](https://discourse.julialang.org/u/tlienart)
#### Post date: [January 1, 2022, 9:49pm UTC](https://discourse.julialang.org/t/how-to-suppress-equation-numbers-in-franklin/73835/6 "2022-01-01T21:49:38Z")

</div>

This is now baked in `#master` and the patch release `0.10.66` (which should be available within the next 10 mins) has it. It introduces:

- the environments `equation*, align*, aligned*, eqnarray*`
- the command `nonumber`

So that for instance:

```julia
\begin{align*}
x &= 4 \\
y &= 7
\end{align*}

```

or

```julia
\nonumber{
$$ x = 5 $$
}

```

would work as indicated above, without perturbing the references. The docs linked to earlier is also fixed ([FAQ - Technical](https://franklinjl.org/faq/technical/#how_to_disable_numbering_of_math_in_display_mode)) to reflect this. A patch release for FranklinTemplates adding the `.nonumber` CSS rule by default to the Franklin sheet will be released within the next 30 minutes too.

Again many thanks for reporting the issue @mpf01.
