-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
Numbered equations #1821
Changes from all commits
39f5121
d179665
66e89c3
f62b3a2
05155b3
7d9bb34
3f47639
4967292
faaaf0c
a42c9c6
0f97f48
b5cf4a2
c4db864
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ function package:_init () | |
return value * SILE.settings:get("math.font.size") / 18 | ||
end | ||
}) | ||
self:loadPackage("counters") | ||
end | ||
|
||
function package.declareSettings (_) | ||
|
@@ -64,21 +65,35 @@ function package:registerCommands () | |
self:registerCommand("mathml", function (options, content) | ||
local mode = (options and options.mode) and options.mode or 'text' | ||
local mbox | ||
local counter = SU.boolean(options.numbered, false) and "equation" | ||
counter = options.counter or counter -- overrides the default "equation" counter | ||
xpcall(function() | ||
mbox = self:ConvertMathML(content, mbox) | ||
end, function(err) print(err); print(debug.traceback()) end) | ||
self:handleMath(mbox, mode) | ||
self:handleMath(mbox, mode, counter) | ||
end) | ||
|
||
self:registerCommand("math", function (options, content) | ||
local mode = (options and options.mode) and options.mode or "text" | ||
local mbox | ||
local counter = SU.boolean(options.numbered, false) and "equation" | ||
counter = options.counter or counter -- overrides the default "equation" counter | ||
xpcall(function() | ||
mbox = self:ConvertMathML(self:compileToMathML({}, self:convertTexlike(content))) | ||
end, function(err) print(err); print(debug.traceback()) end) | ||
self:handleMath(mbox, mode) | ||
self:handleMath(mbox, mode, counter) | ||
end) | ||
|
||
self:registerCommand("math:numberingstyle", function (options, _) | ||
SILE.typesetter:typeset("(") | ||
SILE.call("show-counter", { id=options.id }) | ||
SILE.typesetter:typeset(")") | ||
end) | ||
|
||
|
||
|
||
|
||
|
||
end | ||
|
||
package.documentation = [[ | ||
|
@@ -344,6 +359,18 @@ Finally, here is a little secret. This notation: | |
|
||
\noindent In other words, the notation using \code{&} and \code{\\\\} is only a syntactic sugar for a two-dimensional array constructed with braces. | ||
|
||
\paragraph{Numbered equations} | ||
Equations can be numbered in display mode adding the options \autodoc:parameter{numbered} and \autodoc:parameter{counter}. | ||
When \autodoc:parameter{numbered=true}, the equations are numbered using a default "equation" counter. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpicking: "example" --> “example” with curly typographical quote marks. |
||
A different counter may be set by using the option \autodoc:parameter{counter=id}, and this setting will also enable numbering. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: |
||
The default numbering format is "(xx)", but this style may be overriden by defining a custom \autodoc:command{\math:numberingstyle} function, e.g. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "(xx)" --> I would suggest \autodoc:example{(xx)}` so that it is typeset in the example font (Cormorant Infant currently) as other examples of "rendered content". We could avoid the quote marks here, then: no need for double marking! (But if we want to keep them, then use typographical quote marks. |
||
|
||
\begin[type=autodoc:codeblock]{raw} | ||
\define[command=math:numberingstyle]{(\show-counter[id="equation"])} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not fond of the example using a macro, because macros can't use options, so here this example would always use the "equation" counter regardless of what the user passed to the ... this style may be overridden by defining a custom (By the way, overridden takes two -d-, I think) |
||
\end{raw} | ||
|
||
|
||
|
||
\paragraph{Missing features} | ||
This package still lacks support for some mathematical constructs, but hopefully we’ll get there. | ||
Among unsupported constructs are: decorating symbols with so-called accents, such as arrows or hats, “over” or “under” braces, and line breaking inside a formula. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Lots of extra blank lines inserted!