Skip to content

Commit

Permalink
docs: Add an advanced styling section on equation numbering
Browse files Browse the repository at this point in the history
  • Loading branch information
Omikhleia authored and Didier Willis committed Oct 1, 2024
1 parent 7cca8fa commit 6ae6e1d
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 3 deletions.
4 changes: 3 additions & 1 deletion examples/manual-front.sil
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
\begin{document}
\footnote:rule
\define[command=admon]{%
\define[command=admon]{% This is a quick but bad implementation. We ought to have used a style.
\novbreak
\smallskip%
\novbreak
\set[parameter=document.parindent, value=0]{%
\roughbox[enlarge=true, singlestroke=true, preserve=true,
padding=2%fw, bordercolor=#59b24c, fillcolor=230, shadowcolor=#96A8C7, shadow=false]{%
Expand Down
54 changes: 54 additions & 0 deletions examples/manual-styling/advanced/eqno.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
## Styling equation numbers

Mathematical equations that are displayed on their own line (in the so-called "display" mode) can be numbered.
This feature is not available in Markdown, but is supported for input documents in Djot or SIL.
In Djot, for instance, you can write, using the default `equation` counter:

```
$$`e^{i\pi} = -1`{numbered=true}
```

The equation numbers are then rendered using the `eqno` numbering style, which is defined as follows by default:

```yaml
eqno:
numbering:
display: "arabic"
before:
text: "("
after:
text: ")"
```
But as any style, this can be adjusted to your needs.
For the sake of this example, we could have used old-style numbers, and put the equation numbers in square brackets:
```yaml
eqno:
font:
features: "+onum"
numbering:
display: "arabic"
before:
text: "["
after:
text: "]"
```
Moreover, in Djot or SIL, you can also specify a custom counter to be used for numbering an equation, starting from 1 on its first occurrence, and automatically incremented.
```
$$`e^{i\pi} = -1`{counter=myname}
```

By default, the `eqno` style applies, but if your style definion file contains a style appropriately named `eqno-myname`, it will be used instead.
This is something you will likely want to do, for these custom counters to have a distinct appearance.
Style inheritance is useful here, as you can define a general style for equation numbers, and then override a subset of its properties for specific counters.
For instance, we could want to switch to alpha numbering for this sample `myname` counter:

```yaml
eqno-myname:
inherit: eqno
numbering:
display: "alpha"
```
2 changes: 1 addition & 1 deletion examples/manual-styling/advanced/other.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ Readers experienced with SILE’s standard packages also have to be aware that t
For instance, the (standard) **url** package provides a `urlstyle` hook command. While you could override it---that is, redefine that command---, please note that this is what the resilient classes already do, so as to delegate the decision to a style conveniently called `urlstyle` too.[^other-sile-hooks]

[^other-sile-hooks]: The same principle actually applies to page numbers, relying on the standard **folio** package. The latter provides a `foliostyle` hook, which the resilient styling system overrides with its own clever logic.
Likewise, the `math:numberstyle` hook from the **math** package is also redefined, to rely on the `eqno` style for display math equation numbers (and actually, if it exist and is non-emppty, to the `eqno-⟨counter⟩` style specific to the counter in question, by default `equation`).
Likewise, the `math:numberstyle` hook from the **math** package is also redefined, to rely on the `eqno` style for display math equation numbers (and actually, if it exist and is non-emppty, to the `eqno-⟨counter⟩` style specific to the counter in question, by default `equation`), as described in the previous section.

In other terms, even for standard SILE packages, we may already have provided a style-aware version of their original customization hooks.
3 changes: 2 additions & 1 deletion examples/sile-resilient-manual.silm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ sile:
textsubsuper.fake: false
autodoc.highlighting: true
document.baselineskip: 1.2em
# typesetter.italicCorrection: true # Not yet available in SILE 0.14.x
typesetter.italicCorrection: true # Available in SILE 0.15 (comment out for earlier versions)
packages:
- autodoc-resilient # REQUIRED FOR RESILIENT, do not use regular autodoc
- background # Some of the packages below might not be required...
Expand Down Expand Up @@ -78,6 +78,7 @@ parts:
- manual-styling/advanced/footnotes.md
- manual-styling/advanced/toclevels.md
- manual-styling/advanced/liststyles.md
- manual-styling/advanced/eqno.md
- manual-styling/advanced/other.md
# unfinished
# - manual-styling/captioned.md
Expand Down

0 comments on commit 6ae6e1d

Please sign in to comment.