-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This lua filter will automatically number equations
excluding ones with `\nonumber`
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--[[ | ||
AutoNumber Equation filter – tries to autonumber equations. | ||
Copyright: © 2023 Abhishek Ulayil | ||
License: MIT – see LICENSE file for details | ||
--]] | ||
equation_counter =1 | ||
function Math(el) | ||
if el.mathtype == "DisplayMath" then | ||
if el.text:match('\\#eq:') then | ||
-- skip equation numbering for equations with dedicated labels, | ||
-- but also add them to the tally of equation | ||
equation_counter = equation_counter + 1 | ||
return {pandoc.Str("\n"),el,pandoc.Str("\n")} | ||
elseif el.text:match('\\nonumber') then | ||
-- skip numbering equations with \nonumber | ||
return {pandoc.Str("\n"),el,pandoc.Str("\n")} | ||
else | ||
local text = pandoc.utils.stringify(el.text) | ||
-- insert a label to invoke numbering. | ||
html_label = "eq:".. tostring(equation_counter) | ||
--el.text = [[\label{eq:}]] .. tostring(equation_counter) .. [[}]] .. text | ||
el.text = text .. [[ (\#]] .. html_label .. [[)]] | ||
equation_counter = equation_counter + 1 | ||
end | ||
return {pandoc.Str("\n"),el,pandoc.Str("\n")} | ||
--return el | ||
else | ||
return el | ||
end | ||
end |