How to suppress equation numbers in Franklin?

It seems that Franklin.jl doesn’t currently support the “*” form of math environments, which are used to suppress equation numbers (see this issue). For example, the fragment

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

throws an error:

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

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

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

but it renders as

\[ \notag \alpha \]

How can equation numbers be suppressed?

It’s well explained here:

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.)

2 Likes

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 (and repo) that shows the incorrect reference generated by \eqref.

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

The solution

In your utils.jl copy-paste this:

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:

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

Now if you have something like this:

$$
x = 1 \label{eq1}
$$

\nonumber{
$$
x = 2
$$
}

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

\eqref{eq1} and \eqref{eq2}

It will show this:

(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 · tlienart/Franklin.jl · GitHub.

css trickery

edit if you use

.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…)

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.

1 Like

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:

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

or

\nonumber{
$$ x = 5 $$
}

would work as indicated above, without perturbing the references. The docs linked to earlier is also fixed (FAQ - Technical) 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.

3 Likes