asciidoctor / asciidoctor

:gem: A fast, open source text processor and publishing toolchain, written in Ruby, for converting AsciiDoc content to HTML 5, DocBook 5, and other formats.
https://asciidoctor.org
Other
4.86k stars 791 forks source link

I know AsciiDoctor supports the LATEX. How to generate the number of formulas? #2805

Open diguage opened 6 years ago

diguage commented 6 years ago

I know AsciiDoctor supports the LATEX. I used it a little while age. The feature is far more greate.

I want to generate the numbers of formulas.

I search the user manual, but I did not find the document about it.

The examples are like as following:

<This is my formula.>  (1)

<This is my another formula.>  (2)

or 

<This is my formula.>  (1.1)

<This is my another formula.>  (1.2)

The (1), (2), (1.1) and (1.2) are the numbers of formulas, which are autogenerated.

How to generate the numbers of formulas?

May I custom the style?

mojavelinux commented 6 years ago

If you want to add numbers to formulates, simply set the eqnums attribute on the document.

= Document Title
:stem: latexmath
:eqnums:

[stem]
++++
\begin{equation}
x = y^2
\end{equation}
++++

or

= Document Title
:stem: latexmath
:eqnums: all

[stem]
++++
x = y^2
++++

If eqnums is empty or has the value AMS, the equation must be wrapped in an equation container.

mojavelinux commented 6 years ago

May I custom the style?

I'm not sure. It could be linked to the LaTeX content. See http://docs.mathjax.org/en/latest/tex.html#automatic-equation-numbering. This behavior is controlled by MathJax, not Asciidoctor.

diguage commented 6 years ago

I think Asciidoctor is able to generate a tag containing the sequence number which follows the LaTeX content.

mojavelinux commented 6 years ago

I'm not sure what you mean. Did my suggestion allow you to get the sequence numbers working? They should appear next to the equation as you expect. But the numbers are controlled by MathJax.

diguage commented 6 years ago

I have just tested it, It's OK. Thanks a lot.

I mean:

<tag>This is an equation which is generated by MathJax.</tag> <tag>[the numbers of formulas]<tag>

[the numbers of formulas] is the (1), (2), (1.1), (1.2) and so on.

diguage commented 6 years ago

In the equationNumbers: {} section of The TeX input processor, MathJax can support to configure the format of the equation's number.

How to support to configure the format in Asciidoctor?

diguage commented 6 years ago

MathJax support to referent the equation:

In equation \eqref{eq:sample}, we find the value of an
interesting integral:

\begin{equation}
  \int_0^\infty \frac{x^3}{e^x-1}\,dx = \frac{\pi^4}{15}
  \label{eq:sample}
\end{equation}

\eqref{eq:sample} and \label{eq:sample} are the important elements.

The example is from MathJax TeX and LaTeX Support.

Should the document be added to the Asciidoctor manual?

mojavelinux commented 6 years ago

I think you are referring to this configuration:

http://docs.mathjax.org/en/latest/options/input-processors/TeX.html#configure-tex

Specifically the formatNumber, correct?

I don't know the best way to configure this from the AsciiDoc document. Perhaps the value of the eqnums attribute can be a JavaScript function? That seems awfully low-level, so perhaps it would be better to support standard format options based on a value.

This could also be related to #2493, which would allow you to override the whole MathJax settings. Perhaps a special docinfo file comes into play here.

mojavelinux commented 6 years ago

Some more information in the docs about the equation numbers actually work would certainly be nice.