Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numbered equations #1821

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/math/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ function package:_init ()
return value * SILE.settings:get("math.font.size") / 18
end
})
self:loadPackage("counters")
SILE.scratch.counters.equation = { value = 0, display = "arabic" }
Omikhleia marked this conversation as resolved.
Show resolved Hide resolved
end

function package.declareSettings (_)
Expand Down
14 changes: 14 additions & 0 deletions packages/math/typesetter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ end
local function handleMath (_, mbox, mode)
if mode == 'display' then
mbox.mode = b.mathMode.display
elseif mode == 'numbered' then
leorosa marked this conversation as resolved.
Show resolved Hide resolved
mbox.mode = b.mathMode.display
elseif mode == 'text' then
mbox.mode = b.mathMode.textCramped
else
Expand All @@ -149,6 +151,18 @@ local function handleMath (_, mbox, mode)
end)
SILE.typesetter:endline()
SILE.typesetter:pushExplicitVglue(SILE.settings:get("math.displayskip"))
elseif mode == "numbered" then
SILE.typesetter:endline()
SILE.typesetter:pushExplicitVglue(SILE.settings:get("math.displayskip"))
SILE.typesetter:pushGlue(SILE.nodefactory.hfillglue())
SILE.typesetter:pushHorizontal(mbox)
SILE.typesetter:pushGlue(SILE.nodefactory.hfillglue())
SILE.call("increment-counter", { id="equation" })
SILE.typesetter:typeset("(")
SILE.call("show-counter", { id="equation" })
SILE.typesetter:typeset(")")
leorosa marked this conversation as resolved.
Show resolved Hide resolved
SILE.typesetter:endline()
SILE.typesetter:pushExplicitVglue(SILE.settings:get("math.displayskip"))
else
SILE.typesetter:pushHorizontal(mbox)
end
Expand Down