asciidoctor / asciidoctor-mathematical

An extension for Asciidoctor that converts the content of STEM blocks and inline macros using Mathematical.
MIT License
49 stars 44 forks source link

Support for numbered math? #40

Open bk322 opened 5 years ago

bk322 commented 5 years ago

Python's sphinx allows to number equations by adding label to the directive, and to reference a particular equation by the label value:

.. math::
   :label: 1

   (a + b)^2 = a^2 + 2ab + b^2

See :eq:`1`.

http://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#math

Is it possible to number and reference equations in asciidoctor?

bk322 commented 5 years ago

I'm almost there with

[latexmath#eq1]
++++
(a + b)^2 = a^2 + 2ab + b^2
++++

See link:#eq1[Eq. 1].

But this way I have to number equations manually.

ProgramFan commented 5 years ago

Reference is supported by asciidoctor, check if asciidoctor-latex support numbered equations.

bk322 commented 5 years ago

@ProgramFan thanks, indeed installing it from github:

gem 'asciidoctor-latex', github: 'asciidoctor/asciidoctor-latex'
gem 'thread_safe'

makes numbered math available via

[env.equation#little-fermat]
--
a^{p-1} \equiv 1\ \text{mod}\ p
--

See Eq. (<<little-fermat>>).

Compilation being

asciidoctor-latex -b html5 test.adoc

Sadly it's in MathJax, where as I hoped to get it via mathematical, but it is probably possible to add the numbering bits to mathematical extension of asciidoctor.