Skip to content

Commit

Permalink
Nonumber (#940)
Browse files Browse the repository at this point in the history
* adding nonumber and nonumber envs

* fixing the docs

* patch release
  • Loading branch information
tlienart authored Jan 1, 2022
1 parent cf9e3c7 commit 5f2eeed
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Franklin"
uuid = "713c75ef-9fc9-4b05-94a9-213340da978e"
authors = ["Thibaut Lienart <[email protected]>"]
version = "0.10.65"
version = "0.10.66"

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
4 changes: 2 additions & 2 deletions demos/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ How to make a section expand when clicked, so that content is initially hidden?
<script>
var coll = document.getElementsByClassName("collapsible");
var i;
for (i = 0; i < coll.length; i++) {
coll[i].addEventListener("click", function() {
this.classList.toggle("active");
Expand All @@ -88,7 +88,7 @@ How to make a section expand when clicked, so that content is initially hidden?
With these definitions, the expandible code sections could be added!
\collaps{An additional example: **Press here to expand**}{In the content part you can have latex: $x^2$,
\collaps{An additional example: **Press here to expand**}{In the content part you can have latex: $x^2$,
lists
* Item 1
Expand Down
5 changes: 5 additions & 0 deletions docs/_css/jtd.css
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,11 @@ body { counter-reset: eqnum; }
float: right;
padding-right: 5px; }

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

/* ==================================================================
CODE & HIGHLIGHT.JS
================================================================== */
Expand Down
56 changes: 28 additions & 28 deletions docs/faq/technical.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,41 +56,41 @@ so you can style the back-reference via the `.franklin-content fndef td.fndef-ba

### How to disable numbering of math in display mode?

It is possible to specify in the CSS which Katex equations will be numbered or not by adjusting the
`.katex-display::after` class.
If you want to disable numbering in the entire site, just head to `_css/franklin.css` and remove the `.katex-display::after` block.
You can also build a simple way to disable all numbering inside a specified `@@` div
(see [div blocks](/syntax/divs-commands/#div_blocks))

```markdown
This is numbered:
$$ 1+1 = 2 $$

This isn't:

@@no-number
$$ 2+2 = 4 $$
and
$$ 3+3 = 7-1 $$
@@

Numbered again:
$$ 7 + 1 = 8 $$
```
\note{This is currently only available when you're using KaTeX for maths.}

Use the environment `equation*`, `align*`, `aligned*` or `eqnarray*`. Alternatively, use `\nonumber{...your equation...}`.

You will have to make sure that your CSS sheet contains the following rule:

by adding in the CSS:
```css
.no-number .katex-display::after {
.nonumber .katex-display::after {
counter-increment: nothing;
content: "";
}
```

And possibly [define a command](/syntax/divs-commands/#latex-like_commands) in `config.md`:\
```markdown
\newcommand{\nalign}[1]{@@no-number \begin{align}#1\end{align}@@}
```
if you feel it is more convenient to write `\nalign{3+3 = 6}`.
So for instance using `\begin{align*}...\end{align*}`:

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

Or using `\nonumber{$$ ... $$}`:

\nonumber{
$$
x = 5
$$
}

Recall that numbered equations can be referred to via `\eqref`:

$$
x = 14 \label{eqabc}
$$

like this: \eqref{eqabc}.


## Code
Expand Down
12 changes: 11 additions & 1 deletion src/converter/latex/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ function lx_tableinput(lxc::LxCom, _)
end

"""
\\liteate{...}
\\literate{...}
Resolve a `\\literate{rpath}` (find a literate script and insert it).
"""
Expand All @@ -223,3 +223,13 @@ function lx_literate(lxc::LxCom, lxd::Vector{LxDef})
# then reprocess
return reprocess(read(opath, String), lxd, nostripp=true)
end

"""
\\nonumber{...}
Suppress the displaying of a number.
"""
function lx_nonumber(c, lxd)
PAGE_EQREFS[PAGE_EQREFS_COUNTER] -= 1
return reprocess("@@nonumber " * content(c.braces[1]) * "@@", lxd)
end
15 changes: 11 additions & 4 deletions src/converter/latex/objects.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ const LX_INTERNAL_COMMANDS = [
lxd("style", 2, "~~~<span style=\"!#1\">~~~!#2~~~</span>~~~"),
lxd("tableofcontents", 0, "\\toc"),
lxd("codeoutput", 1, "\\output{#1}"), # \codeoutput{rpath}
# ------------------
# other
lxd("nonumber", 1),
]

"""
Expand All @@ -42,10 +45,14 @@ Convenience function to create pairs (envdname => simple envdef)
lxe(n, k, d=Pair("", "")) = n => LxDef(n, k, d)

const LX_INTERNAL_ENVIRONMENTS = [
lxe("equation", 0, raw"\[" => raw"\]"),
lxe("align", 0, raw"\[\begin{aligned}" => raw"\end{aligned}\]"),
lxe("aligned", 0, raw"\[\begin{aligned}" => raw"\end{aligned}\]"),
lxe("eqnarray", 0, raw"\[\begin{array}{rcl}" => raw"\end{array}\]"),
lxe("equation", 0, raw"\[" => raw"\]"),
lxe("equation*", 0, raw"\nonumber{\[" => raw"\]}"),
lxe("align", 0, raw"\[\begin{aligned}" => raw"\end{aligned}\]"),
lxe("align*", 0, raw"\nonumber{\[\begin{aligned}" => raw"\end{aligned}\]}"),
lxe("aligned", 0, raw"\[\begin{aligned}" => raw"\end{aligned}\]"),
lxe("aligned*", 0, raw"\nonumber{\[\begin{aligned}" => raw"\end{aligned}\]}"),
lxe("eqnarray", 0, raw"\[\begin{array}{rcl}" => raw"\end{array}\]"),
lxe("eqnarray*", 0, raw"\nonumber{\[\begin{array}{rcl}" => raw"\end{array}\]}")
]


Expand Down

2 comments on commit 5f2eeed

@tlienart
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/51528

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.10.66 -m "<description of version>" 5f2eeed71d92d501e471591d873094489aa8811a
git push origin v0.10.66

Please sign in to comment.