Asciidoc not processing stem blocks correctly

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Asciidoc not processing stem blocks correctly

siddjain
I am writing a book and my chapters contain math. I am using asciidoc-mathematical and the

:stem: latexmath

directive at the beginning of every chapter. If I run asciidoc on a chapter itself, the generated PDF has math rendered correctly in it.

But when I try to run asciidoc on my book.adoc which is simply

include::chapter01.adoc[]

include::chapter02.adoc[]

and so on, the math is not rendered correctly.

Additional Information: each of my chapters have a imagesdir defined which is like ../images/<the-folder-for-the-chapter>. E.g.:

:imagesdir: ../images/chapter01

How can I get it to work?
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoc not processing stem blocks correctly

David Jencks
I believe asciidoctor-mathematical doesn’t handle attributes correctly, see Most likely attributes redefined throughout the document are not visible to this extension   In order for it to notice that you set :stem: latexmath you will need to define that at the top of your book.adoc.

For this reason I doubt you can put the images automatically into separate directories for each chapter.  This issue might be relevant, I’m not sure: Generate images into output folder

It’s in a “sometimes works, extremely experimental” stage, but you could try asciidoctor-pdf.js which uses browser rendering and prints to pdf; with that you could use my asciidoctor-mathjax plugin which handles attributes more correctly and also allows you to put the rendered math into your document as inline svg.


And if you want to organize your project with Antora there’s the even more experimental djencks/asciidoctor-pdf.js at antora

David Jencks

On Feb 26, 2020, at 12:33 PM, siddjain [via Asciidoctor :: Discussion] <[hidden email]> wrote:

I am writing a book and my chapters contain math. I am using asciidoc-mathematical and the

:stem: latexmath

directive at the beginning of every chapter. If I run asciidoc on a chapter itself, the generated PDF has math rendered correctly in it.

But when I try to run asciidoc on my book.adoc which is simply

include::chapter01.adoc[]

include::chapter02.adoc[]

and so on, the math is not rendered correctly.

Additional Information: each of my chapters have a imagesdir defined which is like ../images/<the-folder-for-the-chapter>. E.g.:

:imagesdir: ../images/chapter01

How can I get it to work?


If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/Asciidoc-not-processing-stem-blocks-correctly-tp7681.html
To start a new topic under Asciidoctor :: Discussion, [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Asciidoc not processing stem blocks correctly

siddjain
Thanks David.

Its pretty weird because my stem blocks are getting processed but any inline stem is not getting processed.

E.g., this gets processed

[stem]
++++
p = \frac{t}{2^{256}}
++++

but this does not

Geometric Distribution: stem:[p*(1-p)^{n-1}]

and as I said if I run asciidoctor-pdf on the chapter itself, there is no problem. So its very puzzling.
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoc not processing stem blocks correctly

David Jencks
When I was writing asciidoctor-mathjax I ran into a similar inconsistency between block and inline.  I think it has to do with when they are processed, but I don’t really understand the details.  Fixing the algorithm to walk the tree rather than query it and tracking the attributes fixed the problems.

When you process a chapter at a time, the :stem: declaration is in the document attributes so it’s always visible.  My suggestion of putting it at the top of the book.adoc gives the same effect for the book…. does it work?

thanks
David Jencks

On Feb 26, 2020, at 1:22 PM, siddjain [via Asciidoctor :: Discussion] <[hidden email]> wrote:

Thanks David.

Its pretty weird because my stem blocks are getting processed but any inline stem is not getting processed.

E.g., this gets processed

[stem]
++++
p = \frac{t}{2^{256}}
++++

but this does not

Geometric Distribution: stem:[p*(1-p)^{n-1}]

and as I said if I run asciidoctor-pdf on the chapter itself, there is no problem. So its very puzzling.


If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/Asciidoc-not-processing-stem-blocks-correctly-tp7681p7683.html
To start a new topic under Asciidoctor :: Discussion, [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Asciidoc not processing stem blocks correctly

siddjain
My suggestion of putting it at the top of the book.adoc gives the same effect for the book…. does it work?

Yes this works. I had to put :stem: latexmath at top of book.adoc. Its funny the way it works in asciidoc. I can't be sure of anything.
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoc not processing stem blocks correctly

David Jencks


On Feb 26, 2020, at 4:41 PM, siddjain [via Asciidoctor :: Discussion] <[hidden email]> wrote:

My suggestion of putting it at the top of the book.adoc gives the same effect for the book…. does it work?

Yes this works. I had to put :stem: latexmath at top of book.adoc. Its funny the way it works in asciidoc. I can't be sure of anything.

In this case, the problem is in the implementation of asciidoctor-mathematical.  I left an explanation of how to fix it, but I don’t know enough ruby to try to implement the fix.  If you were using asciidoctor.js then asciidoctor-mathjax would work the way you expect :-)

David Jencks


If you reply to this email, your message will be added to the discussion below:
https://discuss.asciidoctor.org/Asciidoc-not-processing-stem-blocks-correctly-tp7681p7685.html
To start a new topic under Asciidoctor :: Discussion, [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML