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

Align inconsistent between asciimath, latexmath, stem blocks #272

Closed
iovuio opened this issue Mar 2, 2019 · 5 comments
Closed

Align inconsistent between asciimath, latexmath, stem blocks #272

iovuio opened this issue Mar 2, 2019 · 5 comments

Comments

@iovuio
Copy link

iovuio commented Mar 2, 2019

A [latextmath] block has the nice feature of centering its content.
Migrating [latexmath] blocks to [stem] blocks left aligns the block content.
Also, the [asciimath] also left aligns.

Please see content below. Only second block is centered.

= Math formulae
:stem:

.asciimath in [asciimath] block
[asciimath]
++++
sum_(i=0)^n i = (n(n+1))/2
++++

.latexmath in [latextmath] block
[latexmath]
++++
\int_0^1 x^n= \frac{1}{n+1}
++++

.latexmath in [stem] block
[stem]
++++
\int_0^1 x^n= \frac{1}{n+1}
++++

Some suggestions

  1. Should stem, asciimath, latexmath align consistently, all center or all left align? I believe yes.
  2. Should centering be the default align for stem, asciimath, latexmath blocks? I believe yes. We can use inlines on a new line to achieve the left align.
  3. Should there be a way to override the default? That would be great!
[stem,align="left|right|center"]
++++
0 ^^ 1 = 0
++++
@mojavelinux
Copy link
Member

It would be nice if they were consistent. But how they are aligned / laid out is not handled by Asciidoctor. It's handled by MathJax. And for some reason, MathJax does it differently.

@iovuio
Copy link
Author

iovuio commented Mar 2, 2019

Indeed, it seems that MathJax has two notation for TeX:

  • displayed mathematics (centered, clear both, what I referred to above as block)
  • in-line mathematics

an only one mode for AsciiMath, which seems to be the inline version. Achieving centered, clear-both as suggested in the docs using styled paragraphs

<p style="text-align:center">
  `x = (-b +- sqrt(b^2-4ac))/(2a) .`
</p>

Closing issue.

@iovuio iovuio closed this as completed Mar 2, 2019
@iovuio
Copy link
Author

iovuio commented Mar 2, 2019

For reference purposes, the linked upstream issue report mathjax/MathJax#2128

@iovuio
Copy link
Author

iovuio commented Mar 2, 2019

Davide of MathJax offered a solution that makes it possible for downstreamers to control how the blocks are displayed. Pull request sent.

@iovuio iovuio reopened this Mar 2, 2019
@mojavelinux
Copy link
Member

I found an even simpler way to do this (since we can rely on the structure of our own HTML).

MathJax.Hub.Register.StartupHook("AsciiMath Jax Ready", function () {
  MathJax.InputJax.AsciiMath.postfilterHooks.Add(function (data, node) {
    if ((node = data.script.parentNode) && (node = node.parentNode) &&
        node.classList.contains('stemblock')) {
      data.math.root.display = "block";
    }
    return data;
  });
});

ggrossetie added a commit to ggrossetie/asciidoctor-chrome-extension that referenced this issue Apr 12, 2019
ggrossetie added a commit to ggrossetie/asciidoctor-chrome-extension that referenced this issue Apr 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants